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:
Imports the necessary name spaces and classes.
Establishes variables required for the different methods.
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.
Implements the six methods from the interface in the order in which they appear in the interface. This is the core of the class.
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
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
Sets up the text fields and buttons.