Description
Method; returns a reference to a locally persistent shared object that is available only to the
current client.
Note: If the user has selected to never allow local storage for this domain, the object is not saved
locally, even if a value for
considerations" on page
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 different directories.
Although the
localPath
especially if other SWF files will need to access the shared object. If the data in the shared object
are specific to one SWF file that will not be moved to another location, then use of the default
value makes sense. If other SWF files need access to the shared object or if the SWF file that
creates the shared object will later be moved, then the value of this parameter can have a profound
effect on whether any SWF files will be able to access the shared object. For example, if you create
a shared object with
other SWF file will be able to access that shared object. If you later move the original SWF file to
another location, then not even that SWF file will be able to access the data already stored in the
shared object.
You can reduce the likelihood that you will inadvertently restrict access to a shared object by using
the
parameter. The most permissive option is to set the
localpath
which makes the shared object available to all SWF files in the domain, but will increase the
likelihood of name collisions with other shared objects in the domain. More restrictive options are
available to the extent that you can append the
contained in the full path to the SWF file. For example, your
the
shared object created by the SWF file at www.myCompany.com/apps/
portfolio
stockwatcher.swf are: "/"; "/apps"; or "/apps/stockwatcher.swf". You will need to determine which
option provides enough flexibility for your application.
Example
The following example creates a shared object that stores text typed into a TextInput component
instance. The resulting SWF file will load the saved text from the shared object when it starts
playing. Every time the user presses Enter, the text in the text field is written to the shared
object.
// create the shared object and set localpath to server root
var my_so:SharedObject = SharedObject.getLocal("savedText", "/");
// load saved text from shared object into myText_ti TextInput component
myText_ti.text = my_so.data.myTextSaved;
// assign an empty string to myText_ti if the shared object is undefined
// to prevent the text input box from displaying "undefined" when
// this script is first run.
if (myText_ti.text == undefined) {
myText_ti.text = "";
}
// create listener object and function for <enter> event
var textListener:Object = new Object();
404
Chapter 6: ActionScript Core Classes
is specified. For more information, see
localPath
398.
, that shared object will not conflict with another object named
portfolio
parameter is optional, developers should give some thought to its use,
set to the default value of the full path to the SWF file, then no
localPath
localPath
parameter with folder names that are
localPath
localPath
"Local disk space
parameter to "/",
parameter options for
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?