SharedObject.getLocal()
Availability
Flash Player 6.
Usage
SharedObject.getLocal(objectName [, localPath])
Note: The correct syntax is
myLocalSO = SharedObject.getLocal
Parameters
The name of the object. The name can include forward slashes (
objectName
work/addresses
following characters:
~ % & \ ; :
An optional string parameter that specifies the full or partial path to the SWF file
localPath
that created the shared object, and that determines where the shared object will be stored locally.
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. If
Flash can't create or find the shared object (for example, if
directory exists), this method returns
Description
Method; returns a reference to a locally persistent shared object that is available only to the
current client.
To avoid name collisions, Flash looks at the location of the SWF file that is creating the shared
object. For example, if a SWF file at www.myCompany.com/apps/stockwatcher.swf creates a
shared object named
that was created by a SWF file at www.yourCompany.com/photoshoot.swf, because
portfolio
the SWF files originate from two different directories.
Example
The following example saves the last frame a user entered to a local shared object
// 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 SWF frame.
// On each frame, call the rememberme function to save the frame number.
function rememberme() {
so.data.frame=this._currentFrame;
so.data.user="John";
}
622
Chapter 12: ActionScript Dictionary
SharedObject.getLocal
.
is a legal name. Spaces are not allowed in a shared object name, nor are the
" ' , < > ? #
null
, that shared object will not conflict with another object named
portfolio
. To assign the object to a variable, use syntax like
localPath
.
); for example,
/
was specified but no such
.
kookie
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?