User Guide
138 Server-Side ActionScript Language Reference
A shared object property can be modified by a client between successive calls to
SharedObject.getProperty() and SharedObject.setProperty(). If you want to
preserve transactional integrity, call the
SharedObject.lock() method before modifying the
shared object; make sure to call
SharedObject.unlock() when you finish making
modifications. If you call
SharedObject.setProperty() without first calling
SharedObject.lock(), the change is made to the shared object, and all object subscribers are
notified before
SharedObject.setProperty() returns. If you call SharedObject.lock()
before you call
SharedObject.setProperty(), all changes are batched and sent when the
SharedObject.unlock() method is called. The SharedObject.onSync handler on the
client side is invoked when the local copy of the shared object is updated.
Example
The following example uses the SharedObject.setProperty() method to create the
property
city with the value San Francisco. It then enumerates all the property values in a
for loop and prints out the results by using a trace() action.
myInfo = SharedObject.get("foo");
var addr = myInfo.getProperty("address");
myInfo.setProperty("city", "San Francisco");
var names = sharedInfo.getPropertyNames();
for (x in names){
var propVal = sharedInfo.getProperty(names[x]);
trace("Value of property " + names[x] + " = " + propVal);
}
See also
SharedObject.getProperty()
SharedObject.size()
Availability
Flash Communication Server MX 1.0.
Usage
mySO.size()
Parameters
None.
NOTE
If only one source (whether client or server) is updating a shared object in a server-side
script, you don’t need to use the
lock() or unlock() methods or the onSync handler.