
Client-Side Communication ActionScript 93
Returns
A reference to an object that can be shared across multiple clients. If Flash can’t create or find the
shared object (for example, if a local path was specified for
persistence but no such directory
exists), returns null.
Description
Method; returns a reference to an object that can be shared across multiple clients by means of the
Flash Communication Server. To create a shared object that is available only to the current client,
use
SharedObject.getLocal.
After issuing this command, use
SharedObject.connect to connect the object to the Flash
Communication Server, as shown below.
con = new NetConnection();
con.connect("rtmp://somedomain.com/applicationName");
myObject = SharedObject.getRemote("mo", con.uri, false);
myObject.connect(con);
To confirm that the local and remote copies of the shared object are in sync, use the
SharedObject.onSync event handler.
All clients that want to share this object must pass the same values for
objectName and URI.
Understanding persistence for remote shared objects. By default, the shared object is not
persistent on the client or server; that is, when all clients close their connections to the shared
object, it is deleted. To create a shared object that is saved locally or on the server, pass a value for
persistence.
Once a value has been passed for the local persistence of a remote shared object, it is valid for the
life of the object. In other words, once you have gotten a remote shared object which is not
locally persistent, you cannot get the same shared object with local persistence while the shared
object is active.
For example, the second line of code in the following example does not get a locally persistent
remote shared object.
// Get a remote shared object (so1) that is persistent
// on the server but not on the client
so1 = SharedObject.getRemote("someObject", nc_uri, true);
// Get a remote shared object (so2) with the same name and path
// as so1, but with local persistence.
// so2 will just point to the same object as so1, and an onStatus
// message will be invoked for so2 with the "code" value of the
// information object set to "SharedObject.BadPersistence".
so2 = SharedObject.getRemote("someObject", nc.uri, "somePath");
Also, remote shared objects that are not persistent on the server are created in a different
namespace from remote shared objects that are persistent on the server. Therefore, if the following
line of code is added to the above example, no SharedObject.BadPersistence error will result
because
so3 does not point to the same object as so1.
so3 = SharedObject.getRemote("someObject", nc.uri, false);
Kommentare zu diesen Handbüchern