494 | Chapter 13: Symmetric Proxy Pattern
proxMove=proxMove.substring(0, proxMove.indexOf("~"));
if (playerNow=="player1" && !monitor[0])
{
playerText.setMove(playerNow);
p1move=proxMove;
monitor[0]=true;
public function takeTurn( ):void
{
rps=new RPS( );
rps.moveComplete(p1move,p2move,playerText,monitor);
rps.displayResults(oppText,p2move);
showText.setMove("ready");
}
Simply change a few 1s to 2s and some 0s to 1s in the key methods in theSymPlayer1
class, and you’re good to go.
Classes and Document Files Support
As big as the two player class implementations are, they would be much bigger if not
for the work done by the supporting classes that create the buttons and dynamic text
fields.
Dynamic Output Text Fields
Because all the data input is done with button entries, the text fields for displaying
data is all typed asDYNAMIC. Example 13-6 shows the class for the text fields.
Example 13-6. DynamicText.as
package
{
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.display.Sprite;
public class DynamicText extends Sprite
{
private var gameInfo:TextField;
private var gameFormat:TextFormat;
public function DynamicText( ):void
{
gameInfo=new TextField( );
addChild(gameInfo);
gameInfo.border=false;
gameInfo.background=true;
gameInfo.type=TextFieldType.DYNAMIC;