Player-Proxy Classes | 491
All the text fields and buttons are user classes and they need to be built prior to test-
ing the class. In the section “Supporting Classes and Document Files” later in the
chapter, you will find the necessary classes for including the buttons and dynamic
text fields.
Move Making
While the player class may seem fairly long and unwieldy, its key elements are quite
simple. Everything is focused on making one of three moves—rock, paper, or scis-
sors. Each move is nothing more than a string.
Event to move
The first step is encapsulated in themakeMove( )function that’s launched by a button
event. Using thenameof the button (not thelabel), an algorithm finds which of the
public function setButton( ):void
{
moveBtn=new MoveButton("Make Move",0xcccccc);
moveBtn.name="move";
addChild(moveBtn);
moveBtn.x=100;
moveBtn.y=50;
rockBtn=new MoveButton("Rock",0xcccccc);
rockBtn.name="rock";
addChild(rockBtn);
rockBtn.x=100;
rockBtn.y=80;
paperBtn=new MoveButton("Paper",0xcccccc);
paperBtn.name="paper";
addChild(paperBtn);
paperBtn.x=150;
paperBtn.y=80;
scissorsBtn=new MoveButton("Scissors",0xcccccc);
scissorsBtn.name="scissors";
addChild(scissorsBtn);
scissorsBtn.x=200;
scissorsBtn.y=80;
connect=new Connect( );
addChild(connect);
connect.x=175;
connect.y=250;
}
}
}
Example 13-5. SymPlayer1.as (continued)