Return to Kroll Design home page

Flash Tutorials (with .FLA files included)

« Return

ActionScript 3

Saving Local Data using SharedObject

You're probably familiar with 'cookies' -- small pieces of information that many web sites save on your computer, or at least attempt to. They may store information such as your highest score in a game, or the last time you visited their web site, for example. Depending on your browser and security settings, you may or may not allow the writing of cookies.

What you may not know is that Flash has the capability to write information to your computer also, using a Flash data type called "SharedObject". For example, on my Windows XP computer, various web sites have stored bits of information in the following folder:

C:\Documents and Settings\David\Application Data\Macromedia\Flash Player\#SharedObjects

If you search for files of type .SOL on your computer, you may well find Flash files from web sites stored on your computer also.

In some ways, it's actually better for a web site to store information on your computer instead of on their own computer. This way, you are in charge of the data's fate, and can delete it if you wish.

The Flash movie below allows you to write some text and Flash goes ahead and stores it on your computer, such that it will be there even after you leave this web site or shut down your pc. To delete the SharedObject file, click the 'Clear' button in the movie. But unfortunately, this does not delete the folder which contains the name of this web site, And if you find the location on your computer where the .SOL files are stored, you'll probably see a list of web sites that users of your computer have visited before. Each .SOL file is contained in a folder that is named after the web site. If you're comfortable with deleting files on your computer, you can go ahead and delete these files and folders, but it's totally up to you, I'm just offering you information, and can't be held responsible if you accidentally delete something you shouldn't, such as your entire Documents and Settings folder!

Download the FLA file

var mySharedObject:SharedObject = SharedObject.getLocal("mydata");

myInput_txt.background = true;
myInput_txt.backgroundColor = 0xffff00;

myData_txt.selectable = false;

function retrieveSavedData() {
if( == null)
{myData_txt.text = "No data found. Type some info in the yellow box and click submit. The data will persist, such that you'll see what you typed the next time you visit this web page. To delete the data off of your computer, click the 'clear' button.";}
{myData_txt.text = "Here is saved data: " +;}


submit_btn.addEventListener(MouseEvent.CLICK, saveData);

function saveData(myEvent:MouseEvent)
{ = myInput_txt.text;

clear_btn.addEventListener(MouseEvent.CLICK, clearData);

function clearData(myEvent:MouseEvent)

« Return

©2012 Kroll Design    781.910.3694
Last modified: 12/31/1969 7:00 PM