Make Flash Animations, Video, Slideshows, Text Effects, Buttons & Menus. Designer Templates, 250 Effects, plus Components & Video Controls

简体中文 繁體中文 Français Español Italiano 日本 Polski Deutsch SWiSHzone.com
SWiSHzone.com Banner
You are here: Home > Community > Tutorials
Community
FREE TOOLS!
Laboratory
Community Overview
Movies
Components
Effects
Screencast Tutorials
> Tutorials
Official Blog
Forums
Other Forums
Request help
Search Tutorials

 All words
 Any words

 Similar words
 Exact words

Number of Results:
Monthly Newsletter
Get our monthly newsletter for all the latest news
competitions, tutorials and tips > Sign Up Now

SWiSH Max: Flash Shared Objects
Creator: Mike Chrysler
Website: http://www.swishzone.com
Submitted: Wed May 23 2007
Description: This tutorial shows you how you can use Flash's Shared Objects to store and retrieve data from your website visitors local system .
Zip File: Download


optimize
 

 

Program: SWiSH Max
Build Date: 2005.08.15


Introduction

Shared Objects are like cookies. They are snippets of data created in the SWF which are stored locally on the user's computer. Other SWF movies (on the same domain) can then retrieve the stored data. An example SWF movie using this method is provided below. The example stores data using the Store button and retrieves it with the Get button.



Checking for an existing .sol and stored data

The shared object (or flash cookie) can be used to determine if a visitor has been to a web page, since we can see if there is data stored from the visitors previous visit.  If the visitor has not been to the web page we need to create the shared object and populate it with data. On a Windows OS PC the data is stored with an .sol extension at "Documents and Settings\userName\Application Data\Macromedia\Flash Player\#SharedObjects." It is possible to store several different .sol files on the user's system. It is also possible to store several variables in each .sol. The default maximum storage of .sol's from any one domain is 100kb. To store more the user must modify their Flash Player's local storage settings.

This is the script used check for an existing .sol and retrieve any existing data:

onLoad () {
so = sharedobject.getlocal("Filename");
_root.MyVar = so.data.word;
}

  • onLoad(): Checks to see if a shared object exists. If the object does not exist the event creates the shared object on a user's machine.

  • so: The name of our shared object stored on the SWF.

  • sharedobject: Defines it as a shared object.

  • getlocal: Retrieves the file

  • "Filename":  The filename that is stored locally as Filename.sol

  • MyVar: The name of a variable in the SWF that our data will be retrieved to.

  • word: The variable name in the Filename.sol that contains our data.

In our script above, if there is data found in the word varialable of our .sol it will be extrated to the SWF's variable named MyVar. If there is no data found MyVar will contain no data.

Storing data on the user's system

This is the script attached to the Store button to store new data on the users's system:

on (press) {
so.data.word=MyInput;
so.flush();
}

  • Flush(): Immediately writes a locally persistent shared object to a local file.

Retrieving the stored data

This is the script attached to the Get button to extract the stored data from the user's system:

on (press) {
_root.MyVar = so.data.word;
}

Summary

Flash shared-objects (Flash cookies) enable Flash movies to save data which persists on a user's system across multiple sessions or visits to the Flash movie.

They can be used to store user preferences, or to check whether a visitor is new or returning.

The shared-object can only be read by movies from the same domain as the movie that created the shared-object.



Search | Privacy policy | Contact us | Site Map | Copyright SWiSHzone.com Pty Ltd 1999-2010