O'Reilly logo

ActionScript 3.0 Design Patterns by Chandima Cumaranatunge, William Sanders

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

Information Shared over the Internet

At this point we need to take a little detour to discuss the techniques we used to send data over the Internet for proxy work. As noted earlier in this chapter, we have chosen to use Flash Media Server 2 to pass the move information from a player to its proxy over the Internet. In order to see the relationships involved, we will show the purely FMS2 server-side script and those portions of the player/proxy class that use it.

To begin, Example 13-4 shows the proxygame.asc file (all lowercase). It is written in ActionScript 1.0 because, at the time of this writing, all the code written for the server-side could only be written in Server Side Communication ActionScript (SSCA). The client-side counterpart is all ActionScript 3.0. This file sits in the server-side location of the FMS2 host server. Generally, the host for the SWF files containing the compiled application and the server-side .asc file are on the same host, but not always. The connection to the server is through an RTMP protocol that's part of the client-side script.

Example 13-4. proxygame.asc

application.onAppStart=function() { trace(this.name + " is reloaded"); this.ss_so = SharedObject.get("proxmove",false); this.dup1=false; this.dup2=false; }; //------------------------ application.onConnect=function(currentClient,username) { currentClient.name=username; if(currentClient.moveNow==null) { currentClient.moveNow="ready"; } var cl=application.clients.length; //Check username and see if ...

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