As shown in the figure,
This tutorial utilizes the dataset and list components of Flash to achieve an automatic recording function similar to IE forms. The main methods used are: Dataset.loadfromsharedobj (object name, local path);
Dataset. Savetosharedobj (object name, local path);
Dataset.addsort () First, drag the component dataset,textinput,list onto the main scene. Respectively named My_ds, My_input, My_list. Then, write the as code on the key book as follows: Import mx.data.components.datasetclasses.dataseterror;//DataSet error handling
var inputid:string = "inputID04";
Identity in the client cache that resembles a cookie
function Loadstr (ID) {//import locally stored data and write to list
My_ds.loadfromsharedobj (ID, "/");
var _length:number = my_DS.items.length;
key = ID;
if (my_ds.length!= 0) {
Sort data by date
if (!my_ds.hassort (key)) {
My_ds.addsort (Key, ["date"], datasetiterator.descending);
My_ds.usesort (key, datasetiterator.descending);
} else {
My_ds.usesort (key, datasetiterator.descending);
}
}
My_ds.last ();
For (i=0 i<_length; i++) {//display of records in the list component
This.my_list.addItem ({label:my_DS.currentItem.Str});
My_ds.previous ();
}
}
function Setstr (ID) {
Characters stored in TextInput
My_ds.loadfromsharedobj (ID, "/");
var now:date = new Date ();
My_ds.additem ({Str:this.my_input.text, Date:now.getTime ()});
My_ds.savetosharedobj (ID, "/");
}
function init (ID) {//initialization, exporting a local dataset
try {
My_ds.loadfromsharedobj (ID, "/");
} catch (E:dataseterror) {
My_ds.savetosharedobj (ID, "/");
}
Loadstr (ID);
}
Init (inputID);
var tilistener:object = new Object ();
Tilistener.handleevent = function (evt_obj:object) {
if (Evt_obj.type = = "Enter") {
Record the input when the user presses ENTER
Setstr (inputID);
}
};
Add listeners.
My_input.addeventlistener ("Enter", Tilistener);