Shared Objects in Flash AS 3.0 - getW3Help.com - Free Web Tutorials and Resources
Subscribe
Stay Updated
Shared Objects in Flash AS 3.0
Posted on Nov 26, 2008 by Makubex, 3 comments
In this tutorial, let us see how to use Shared Objects in Actionscript 3.0
Flash CS3, AS 3.0



Shared Objects are used to store information on the user machine. For example, you can store your website template settings. The data will be stored till the user clears his/her temporary memory of the machine.

In this example let us store a string in the user machine and we will retrieve it using shared objects.

In the below example after saving a data, refresh the page and click on retrieve button to get the saved data.

Demo:



Download Source Files

Concept:

1. Declaring Shared Object,

var myso:SharedObject;


2. Creating shared object on the client local machine..

myso = SharedObject.getLocal("myApp");

"myApp" is like unique ID, it has to be different for each flash applications you develope. We will access the values using this ID.

3. Storing data to shared object..

myso.data.val = "Data to be Stored";


"val" is the variable name.

4. Delete Shared Object..

delete myso.data.val;


5. Closing shared object..

myso.close();

After the Shared Object has been used, its wise to close it.

- End of Tutorial

Labels: ,

Comments
Post a Comment

Hi is there a way to create Hello,
I have a Flash movie that that I want to play once on page hit, but not again when a user refresh. Is there a way to make it play once per user visit to the website?

Any help would be great appreciated.


Thanks
T-

By OpenID FORBIDDEN, at March 24, 2009 10:42 AM  

hi..
please help me how to create code when user click his name from a list name that has stored in shared object to another scene that belong to his (name) data.
Thank you

By Blogger mama, at May 26, 2009 8:56 PM  

Forbidden and Mama, the best way to find that out would be to open up flash and play around in actionscript. I just started but I am learning much of actionscript because I follow a tutorial, then add to it and play around with it until i create something else. Good luck!

By OpenID thagrimiestone, at June 25, 2009 9:56 AM  


Hi, I am Karthikeyan VJ (aka makubex). I am a independent Interactive Developer and I am currently focusing on Flash, Flex and AIR