
Client-Side Communication ActionScript 97
To minimize network traffic, this method is not called when a client “changes” a property to the
same value it currently has. That is, if a property is set to the same value multiple times in a row,
this method is invoked the first time the property is set, but not during subsequent settings, as
shown in the following example:
so.data.x = 15;
// The following line invokes onSync
so.data.x = 20;
// The following line doesn’t invoke onSync,
// even if issued by a different client
so.data.x = 20;
Example
// Create or get a remote shared object named 'position',
// nc is the NetConnection created earlier in code,
// false means do not make this a persistent so.
so = SharedObject.getRemote("position", nc.uri, false);
// Update ball position when another participant moves the ball
// sharedBall_mc is a movie clip on the stage.
so.onSync = function(list) {
sharedBall_mc._x= so.data.x;
sharedBall_mc._y= so.data.y;
}
// You must always call connect() in order to successfully
// connect to the shared object and share data.
so.connect(nc);
See also
SharedObject.data
SharedObject.send
Availability
• Flash Player 6.
• Flash Communication Server MX.
Usage
myRemoteSharedObject.send(handlerName [,p1, ...,pN])
Parameters
handlerName A string that identifies the message; also the name of the ActionScript handler to
receive the message. The handler name can be only one level deep (that is, it can’t be of the form
parent/child) and is relative to the shared object.
Note: Do not use a reserved term for a handler name. For example, mySO.send("close") will fail.
p1, ...,pN Optional parameters that can be of any type. They are serialized and sent over the
connection, and the receiving handler receives them in the same order. If a parameter is a circular
object (for example, a linked list that is circular), the serializer handles the references correctly.
Returns
Nothing.
Commentaires sur ces manuels