User Guide

SharedObject 591
getLocal (SharedObject.getLocal method)
public static getLocal(name:String) : SharedObject
Returns a reference to a locally persistent shared object that is available only to the current
client. If the shared object does not already exist,
getLocal() creates one. This method is a
static method of the SharedObject class.
Note: In Flash Lite, a shared object cannot be shared between two SWF files.
To assign the object to a variable, use syntax like the following
var so:SharedObject = SharedObject.getLocal("savedData")
Because the data may not be immediately available for reading on the device, the application
must create and register a listener for the shared object identified by
name. For details, see the
description of the
addListener() method.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
name:String - A string that represents the name of the object. The name can include forward
slashes (
/); for example, work/addresses is a valid name. Spaces are not allowed in a shared
object name, nor are the following characters:
~ % & \ ; : " ' , < > ? #
Returns
SharedObject - A reference to a shared object that is persistent locally and is available only to
the current client. If Flash can't create or find the shared object,
getLocal() returns null.
This method fails and returns
null if persistent shared object creation and storage by third-
party Flash content is prohibited by the device.
Example
The following example saves the last frame that a user entered to a local shared object named
kookie:
// Get the kookie
var my_so:SharedObject = SharedObject.getLocal("kookie");
// Get the user of the kookie and go to the frame number saved for this
user.
if (my_so.data.user != undefined) {
this.user = my_so.data.user;
this.gotoAndStop(my_so.data.frame);
}