
Client-Side Communication ActionScript 81
Example
The following example shows how this value increments for a publishing stream.
myStream.publish("someData", "live");
// After 10 seconds, myStream.time = 10
// You then stop publishing for a while
myStream.publish(false);
// Later you resume publishing on the same stream
// either the same feed or a different feed
myStream.publish("otherData", "live");
// After 10 seconds, myStream.time = 20
See also
NetStream.close, NetStream.play, NetStream.publish
SharedObject (object)
Availability
• Flash Player 6.
• Flash Communication Server MX (not required).
Shared objects are quite powerful: they offer real-time data sharing between multiple client
movies 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 Communication
Server. For example, you can call
SharedObject.getLocal to create a shared object, such as a
calculator with memory, in the player. Because the shared object is locally persistent, Flash
saves its data attributes on the user’s machine when the movie ends. The next time the movie
runs, the calculator contains the values it had when the movie ended. Alternatively, if you set
the shared object’s properties to
null before the movie ends, the calculator opens without any
prior values the next time the movie runs.
• Storing and sharing data on a server
A shared object can store data on the Flash Communication 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.
Commentaires sur ces manuels