User Guide

Understanding application flow 35
After the client is connected to the shared object, the server sends out a synchronization
message for the shared object, which is handled by the
SharedObject.onSync event handler
defined on the client. When the client, the server, or any other movie instance makes a change
to the shared object, the server again sends out a synchronization message for the shared
object.
Each synchronization message contains a code that specifies the nature of the change that
occurred to the shared object. The code changes depending on the circumstances. For
example, when a client first connects to a shared object, the code that accompanies the
synchronization message has a value of
clear; a value of success indicates that the client
successfully modified the contents of the shared object. For a complete list of codes and their
descriptions, see the
SharedObject.onSync entry in the Client-Side ActionScript Language
Reference for Flash Media Server 2.
The following diagram illustrates a scenario in which two clients, Client 1 and Client 2,
connect to the same remote shared object,
obj1. When each client first connects to the shared
object, a
clear synchronization message is returned by the server. Client 1 then modifies a
data property of
obj1, called x, setting it equal to 4. Client 1 receives a success
synchronization message, indicating that the change to the shared object was successful;
Client 2 receives a
change synchronization message, indicating that the obj1 shared object is
modified.
Shared object flow
SERVER FLOW
Sync
(Initialize data)
Sync
(Update data)
CLIENT 1 FLOW
onSync
"clear"
obj1.data.x=4
onSync
"success"
getRemote("obj1")
connect
CLIENT 2 FLOW
onSync
"clear"
onSync
"change"
getRemote("obj1")
connect