O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17.5. Communicating Between Movies on Different Computers

Problem

You want to create a channel of communication between two or more movies on different computers.

Solution

Create a remote shared object and connect each of the clients to it.

Discussion

LocalConnection objects can be used to communicate between movies on the same computer but not on different computers. Remote shared objects offer a way to create channels of communication between multiple computers acting as clients of a FlashCom application. Remote shared objects can be either persistent or nonpersistent. In most cases where you simply want to create a channel of communication between FlashCom clients, there is no need to create a persistent shared object (in which the data is stored to disk). On the other hand, if you want to save the data between sessions or restarts of the FlashCom application, you should make the shared object persistent, as discussed in Recipe 16.6.

Each client must create a client-side remote shared object using the SharedObject.getRemote( ) method and connect using the connect( ) method:

// Create a nonpersistent client-side RSO and connect it to the server. This example
// assumes that you have an existing net connection object named myConnection.
myClient_r_so = SharedObject.getRemote("clientComRSO", myConnection.uri, false);
myClient_r_so.connect(myConnection);

See Also

See the Introduction to Chapter 16 as well as Recipe 16.6 for more information regarding remote shared objects and the details ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required