Implementation of Flash textinput input box automatic filling function

Source: Internet
Author: User
Tags error handling
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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.