1. Create a new FLA
2. Create a basic form (fig1)
-
create
a multiline input text field an give the name myText to the Instance (fig2)
- You can insert a submit button (the data won't be submitted in our tutorial but it could be sent to a php script or ASP or whatever) called the instance of your button myButton
- You can insert a scrollbar on your text field if necessary.
fig1 fig2
3. Now that we have created a basic form we want to write some code that will:
- retrieve or create a shared object.
- If the shared object exists it will load the saved data in the text field if not it will create it.
- detect when the user type something new in the text field.
- if something is typed we need to write the data immediately to a shared object.
- when the submit button is pressed we can safely delete the shared object.
To create or retrieve the shared object we use the following syntax :
| var myCookie:SharedObject = SharedObject.getLocal("mySavedData"); |
Above I use strict data typing but you might as well write :
| var myCookie = SharedObject.getLocal("mySavedData"); |
The code above stores a reference to the shared object in the variable myCookie. If the shared object exists the properties of mySavedData (our shared object) are stored in myCookie and can be retrieved. If the shared object doesn't exist it creates it.
continue to next page... |