|
|
Search Tutorials
Creating a shared objectFirst, we have to create a local shared object within a Flash movie. To do so, just put this line of code in the first frame of your movie:
local_data = SharedObject.getLocal("user_data");
Now we have created an Object named "local_data" which is associated with a shared object on the local hard-drive named user_data. Note that in the feature, this data can be read from other movies from the same domain that created the Shared Object.
Writing dataLets store something in our fresh created Shared Object. Lets say, we want to store the user's name and his age in it. To do so, use this:local_data.data.user_name = "John Smith"; local_data.data.user_age = 23; local_data.flush ()Note that this code must be in the same level where you have created the Shared Object. The flush () command is optional, it is used to write the information to disk immediately. If you don't use this command, Flash MX writes the shared object to a file when the SWF movie is closed or when the shared object is garbage-collected because it no longer has any references to it.
|
||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||
|