Recipe 17.5 Communicating Between Movies on Different Computers

17.5.1 Problem

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

17.5.2 Solution

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

17.5.3 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);

17.5.4 See Also

See the Introduction to Chapter 16 as well as Recipe 16.6 for more information regarding remote shared objects and the details of the get( ), getRemote( ), and connect( ) methods. See Recipe 17.6 for further information on using an RSO to communicate between connected FlashCom clients. Also refer to Recipe 14.15 and Recipe 17.1.



ActionScript Cookbook
ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers
ISBN: 0596526954
EAN: 2147483647
Year: 2005
Pages: 425

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net