
50
Every shared object is identified by a unique name and contains a list of name-value pairs, called
properties, just like any other ActionScript object. A name must be a unique string and a value can
be any ActionScript data type. (For more information about data types, see Using Flash MX.) All
shared objects have a data property. Any property of the data property can be shared and is called
a slot.
A shared object can be owned by the current (local) application instance or by a different (remote)
application instance. The remote application instance can be on the same server or on a different
server. References to shared objects that are owned by a remote application instance are called
proxied shared objects.
The slot of a shared object owned by the local instance can be modified by multiple clients or by
the server simultaneously; there is no conflict on the server side when a shared object is modified.
For example, a call to
SharedObject.getProperty returns the latest value and setting a new
value assigns a new value for the named slot and updates the object version. If you write a server-
side script that modifies multiple properties, you can prevent other clients from modifying the
object during the update, by calling the
SharedObject.lock method before updating the object.
Then you can call SharedObject.unlock to commit the changes and allow other changes to be
made. Any change to a shared object results in notification to all the clients that are currently
subscribed to the shared object.
When you get a reference to a shared object owned by a remote application instance, any changes
made to the object are sent to the instance that owns the object. The success or failure of any
changes are sent using the
SharedObject.onSync event handler, if it is defined. Also, the
SharedObject.lock and SharedObject.unlock methods cannot be used to lock or unlock
proxied shared objects.
Komentáře k této Příručce