Server-Side Communication ActionScript > SharedObject.setProperty |
![]() ![]() ![]() |
SharedObject.setProperty
Availability
Flash Communication Server MX.
Usage
sharedInfo.setProperty(name
,value
);
Parameters
name
The name of the property in the shared object.
value
An ActionScript object associated with the property, or null
to delete the property.
Returns
Nothing.
Description
Method; updates the value of a property in a shared object. A shared object property can be modified by another user of the shared object between successive calls to SharedObject.getProperty
and SharedObject.setProperty
. If you want to preserve transactional integrity, call the SharedObject.lock
method before operating on the shared object; be sure to call SharedObject.unlock
when the operations finish. If you don't call SharedObject.lock
and the SharedObject.setProperty
is called, the change is made to the shared object, and all subscribers of the object are notified before SharedObject.setProperty
returns. If a call to the SharedObject.lock
method precedes a call to SharedObject.setProperty
, all changes are batched and sent when the SharedObject.unlock
method is called.
If you call SharedObject.setProperty
on the server side, it invokes a change message in the SharedObject.onSync
method on the client side for any Flash Player client that is using the shared object. The name
parameter on the server side is the same as an attribute of the data
property on the client side. For example, the following two lines of code are equivalent: the first line is server-side ActionScript, and the second is client-side ActionScript:
sharedInfo.setProperty(nameVal, "foo"); clientSO.data[nameVal] = "foo";
Example
This 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 in the Output window 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
![]() ![]() ![]() |