
88
Example
The following example connects to a shared object and initializes it.
function getMaster()
{
trace("getMaster called");
master = SharedObject.getRemote("master", con.uri, true);
connVal = master.connect(con);
if (connVal) print("Connection was successful");
else print("Unable to connect the shared object with the given NetConnection
object");
master.onSync = function (listVal) {
getPlayList();
trace("SO: " + so.data[currentPlaylist]);
}
}
See also
NetConnection (object), SharedObject.getRemote, SharedObject.onSync
SharedObject.data
Availability
• Flash Player 6.
• Flash Communication Server MX (not required).
Usage
myLocalOrRemoteSharedObject.data
Description
Read-only property; the collection of attributes assigned to the data property of the object; these
attributes can be shared and/or stored. Each attribute can be an object of any of the basic
ActionScript or JavaScript types—Array, Number, Boolean, and so on. For example, the
following lines assign values to various aspects of a shared object:
itemsArray = new Array(101,346,483);
currentUserIsAdmin = true;
currentUserName = "Ramona";
so.data.itemNumbers = itemsArray;
so.data.adminPrivileges = currentUserIsAdmin;
so.data.userName = currentUserName;
All attributes of a shared object’s data property are available to all clients connected to the shared
object, and all of them are saved if the object is persistent.
Note: Do not assign values directly to the data property of a shared object, as in so.data = someValue; Flash
ignores these assignments.
If you assign null or undefined to the attribute of a remote shared object, Flash deletes the
attribute, and
SharedObject.onSync is invoked with a code property of "delete". To delete
attributes for local shared objects, use code like
delete so.data.attributeName; setting an
attribute to
null or undefined for a local shared object does not delete the attribute.
Comentários a estes Manuais