Macromedia flash media server 2-client-side actionscript language reference for flash media server 2 Benutzerhandbuch

Seite von 156
112
Client-Side ActionScript Language Reference
SharedObject class
Availability
Flash Player 6.
Flash Media Server (not required).
Shared objects are quite powerful: they offer real-time data sharing between multiple client 
SWF files and objects that are persistent on the local or remote location. You can think of 
local shared objects as “cookies” and remote shared objects as real-time data transfer devices. 
Common ways to use shared objects are summarized below.
Maintaining local persistence
This is the simplest way to use a shared object, and does not require Flash Media Server. 
For example, you can call 
 to create a shared object, such as a 
calculator with memory, in Flash Player. Because the shared object is locally persistent, 
Flash saves its data attributes on the user’s machine when the application ends. The next 
time the application runs, the calculator contains the values it had when the application 
ended. Alternatively, if you set the shared object’s properties to 
null
 before the application 
ends, the calculator opens without any prior values the next time the application runs.
Storing and sharing data on a server
A shared object can store data on the Flash Media Server for other clients to retrieve. For 
example, you can open a remote shared object, such as a phone list, that is persistent on 
the server. Whenever a client makes any changes to the shared object, the revised data is 
available to all clients that are currently connected to the object or who later connect to it. 
If the object is also persistent locally and a client changes the data while not connected to 
the server, the changes are copied to the remote shared object the next time the client 
connects to the object.
Sharing data in real time
A shared object can share data among multiple clients in real time. For example, you can 
open a remote shared object that stores real-time data, such as a list of users connected to a 
chat room, that is visible to all clients connected to the object. When a user enters or 
leaves the chat room, the object is updated and all clients that are connected to the object 
see the revised list of chat room users.