Accessibility
 
Home > Products > Flash > Support > Using ActionScript
Flash Icon Macromedia Flash Support Center - Using ActionScript
SharedObject.getLocal

Availability
Flash Player 6

Usage
SharedObject.getLocal( objectName [, localPath ])

Note: The correct syntax is SharedObject.getLocal. To assign the object to a variable, use syntax like myLocalSO = SharedObject.getLocal.

Parameters
objectName The name of the object. The name can include forward slashes ( / ); for example, work/addresses is a legal name. The following characters (as well as a space) are not allowed in a shared object name: ~ % & \ ; : " ' , < > ? #

localPath An optional string parameter that specifies the full or partial path to the SWF file that created the shared object. This string is used to determine where the object will be stored on the user's computer. The default value is the full path.

Returns
A reference to a shared object that is persistent locally and is available only to the current client.

Description
Method; returns a reference to a locally persistent shared object that is available only to the current client.

To avoid name collisions, Macromedia Flash MX looks at the location of the movie that is creating the shared object. For example, if a movie at www.myCompany.com/apps/stockwatcher.swf creates a shared object named portfolio , that shared object will not conflict with another object named portfolio that was created by a movie at www.yourCompany.com/photoshoot.swf, because the movies originate from two different directories.

Example
The following example saves the last frame a user entered to a local shared object kookie .

// Get the kookie
so = sharedobject.getlocal("kookie");

// Get the user of the kookie and go to the frame number saved for this user.
if (so.data.user != undefined) {
	this.user = so.data.user;
	this.gotoAndStop(so.data.frame);
}

The following code block is placed on each movie frame.

// On each frame, call the rememberme function to save the frame number.
function rememberme() {
	so.data.frame=this._currentFrame;
	so.data.user="John";
}

See also
SharedObject.flush, SharedObject.getSize

To Table of Contents Back to Previous document Forward to next document