Use SharedObject to save data on users computer
March 24th, 2009By using SharedObject you are able to store limited amounts of data on a user's computer. It's works in the same kind of way that your browser stores cookies. However there are some limitations with using this. Sometimes swf files may not be able to write the data, and the data can sometimes be deleted without your knowledge. Users can set their own limits on how much space flash player can use on their computer. When they lower the amount of disk space available, some local shared objects might get removed.
I'll show you a basic example of using SharedObject. We will have an input text field on stage and a button that will save the text in the text field.
Create a new AS3 Document and put a text field on stage and give it an instance name. I will call mine theText_txt.
Next make a button on stage and give it an instance name. I called mine save_btn.
Create a new layer in the main timeline and call it actions and lock it. Open up the actions panel and enter the following:
var mySO:SharedObject; mySO = SharedObject.getLocal("myfirstSO");
The first line creates the shared object. The second line gets a local shared object called myfirstSO. Nothing is stored in it at the moment but we will assign data to it shortly.
Now when we click the button we want to assign whatever text is in the text field to the shared object. In the actions panel enter:
save_btn.addEventListener(MouseEvent.CLICK, saveText); function saveText(e:MouseEvent):void { mySO.data.myText = theText_txt.text; }
This has now assigned the text in the text field to a variable called myText in the SharedObject.
OK now that the text is saved we will want to populate the text field with that saved data when you open the swf again. In the actions panel enter the following.
if (mySO.data.myText) { theText_txt.text = mySO.data.myText; }
This checks to see if there is any data in the myText variable in the SharedObject. If there is then it assigns that value to the text field.
Now test the movie. Enter some text in the text field and click your save button. Close the swf and test the movie again. You will see that the text you entered before is in the text field.
You can download the example here: SharedObject.zip
Hope this was helpful,
Ed

When coding in actionscript sometimes it can be a pain that you don't get code hinting with objects that are on stage. A good way of overcoming this is to change the instance names of your objects (Movie Clips, Buttons, etc.) to have an underscore "_" then the abbreviated name of that object at the end of the name.
In the first meeting of 