Photoshop Tutorials, Flash Tutorials, 3Ds Studio Max Tutorials, Web Design Tutorials

Home  |  Submit Tutorial  |  Top Sites  |  Free Templates (NEW)  |  Website templates  |  Privacy Policy  |  Link Exchange  |  Contact Us

Recommended Hosting:
Host Unlimited Domains on 1 Account
1500GB storage and 15000GB bandwidth for $6.95/mo!
Recommended Hosting:
Host Unlimited Domains on 1 Account
1500GB storage and 15000GB bandwidth for $6.95/mo!

Welcome To Flash Tutorials Area - Using Local Shared Objects in Flash MX

Before Flash MX, it was pretty tricky to "remeber" the data in a Flash movie - it could be done with a standard browser cookie, which was hard to implement for someone with intermediate Flash skills, using a 3rd party script such as PHP or ASP or (in offline Flash applications) with the undocumented fscommand "save". Flash MX's Shared objects allow to store and retrieve the information within a Flash movie easily. Lets see how it works.

What is a local shared object ?

Flash MX Shared objects is a new feature allow you to store information at the user's machine the same way as cookies would and retreive it at a later time. Shared objects could be used to remember the user's name, the number of the level he last played in a game, his highscore or anything else you can imagine.

Shared objects are stored in .sol files located in the Flash player directory of the user's profile : "C:/Documents and Settings/Administrator/Application Data/Macromedia/Flash Player", and have their own format

Here is a working example of a movie using the Shared Object. Type in your name and age and click on "Save". Then, refresh this page to let Flash read and display the stored data:

Creating a shared object

First, 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 data

Lets 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: = "John Smith"; = 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.

Reading data

To retrieve data from a saved Shared Object, just use the following syntax:

stored_user_name =;
stored_user_age =;

Don't forget that you still have to create the local_data shared object first. Now, the user's name is stored in a variable called "stored_user_name" and the user's age in the variable "stored_user_age"and you can use it anywhere in your movie.

You can store more information in one Shared Object file in the same way.

Similar to the way how we have saved simple text variables you can store whole arrays and other objects.

Important notices

There are some important things to remember when using the local Shared Objects in your movies:

  1. The primary drawback of shared objects is that it can be overwritten/disabled/erased by the user (right click on the swf, and click on settings), so avoid to store information which is absolutely necessary to let the application work properly. Think of it as an additional feature.

  2. The amount of the information you can store in a local Shared Object from one domain is set to 100 kb by default. If you will try to store more information, the Flash player will ask the user for a permission to increase this limit. Be sure the stage of your movie is at least this is the minimum size Macromedia Flash MX requires to display the dialog box.


Premium Partners

  Free Website Templates - Flash templates, Affordable Website Design, Website Templates, Website Redesign, Custom Website Design, Web Design Tutorials, Flash Tutorials, Promotion Tutorials - that is what we do. Metamorphosis Design Studio offers quality, free and low cost web site templates for your business and personal life, we also offer affordable web design and site re-design.
  Vertex Website Tempales - It saves tones of time and money to use pre-made web designs to build your web site. You need a web site but you don't want to pay thousands dollars to professional web design companies? Our web templates is just for you! They are designed to be easilly edited by your favorite html editor, like MS FrontPage
  Website Design Tutorials - Web site design is an area that simply takes experience to perfect. Get started with these tutorials covering everything from page layout to content tips. At you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced Adobe Photoshop, Macromedia Flash MX and 3D Studio Max software.
Free website templates and paid web templates are great tools to make your websites look perfect! You will save time and money with our flash templates and free website templates Our visitors are satisfied with the quality of our free and paid website templates! Please visit our free website templates and paid website templates sections. We offer free web templates, free web layouts, free web page templates and other stuff for free download. All templates come with the html and external css file so you may easily edit HTML with your favorite HTML editor. Feel free to download our free web templates for your personal websites.

Terms of use depend upon the website template vendor.

Home  |  Submit Tutorial  |  Top Sites  |  Free Templates  |  Website templates  |  Privacy Policy  |  Contact Us

All Right Reserved by