130
Client-Side ActionScript Language Reference
Similarly, you can use
persistence
to let SWF files in different directories in the same
domain read and write each other’s shared objects. For example, if the full path to the SWF
file is www.macromedia.com/a/b/c/d/foo.swf,
persistence
can be any of the following:
■
"/"
■
"/a/"
■
"/a/b/"
■
"/a/b/c/"
■
"/a/b/c/d/"
■
"/a/b/c/d/foo.swf/"
By specifying a partial path for
persistence
, you can let several SWF files from the same
domain access the same shared objects. For example, if you specify "/a/b/" for the SWF file
named above and also for a SWF file whose full path is www.macromedia.com/a/b/foo2.swf,
each SWF file can read shared objects created by the other SWF file. When specifying
persistence
, do not include a domain name.
To specify that the path for
persistence
should be the same as the SWF file, without having
to explicitly specify its value, you can use
MovieClip._url
:
var myRemote_so:SharedObject = (name, uri, _root._url);
Example
The following example illustrates the sequence of steps required to create a nonpersistent
remote shared object.
// Open connection to server.
var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://myServer.myCompany.com/someApp");
//
/* The URI for the shared object must be the same as
the URI of the NetConnection it's using. */
var myRemote_so:SharedObject = SharedObject.getRemote("myObject",
my_nc.uri);
my_so.connect(my_nc);
See also
NetConnection class
,
SharedObject class
,
SharedObject.connect()
,
SharedObject.getLocal()
,
SharedObject.onSync