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

Player-Proxy Classes

The main implementation of the ISymPlayer is in two classes, each representing one of two players. The classes are virtually identical except for identifying themselves as either "player1" or "player2" to the media server. Also, each contains a proxy for its opponent, giving it the androgynous character described previously in this chapter.

Example 13-5 shows the script for the entire class. It can be broken down into six parts:

  1. Imports the necessary name spaces and classes.

  2. Establishes variables required for the different methods.

  3. Contains the Constructor function. This includes all of the necessary connection statements, calls to the text field and button functions, and event listeners for the four buttons.

  4. Implements the six methods from the interface in the order in which they appear in the interface. This is the core of the class.

  5. Checks to see if connection has been made and if so, turns on the connection light and sets up the client-side shared object. Also, this function establishes the shared object and connects the shared object through the NetConnection instance (nc). Finally, it calls the server-side script function checkPlayNum(). This call is a "bounce" in that it triggers the server-side function that sends the number of connected users right back to the client-side function numConnect().

  6. Sets up the text fields and buttons.

By placing Example 13-4 and Example 13-5 side by side, you can better see the interaction between the client-side class and the ...

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