ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Player-Proxy Classes | 489

playerText.setMove("player1");
if (!monitor[0])
{
p1move=locMove;
monitor[0]=true;
}
//Check to see if both have moved
monitor[2]=(monitor[0] && monitor[1]);
if (monitor[2])
{
takeTurn( );
}
}
//
//onProxyMove: Info from server
//
public function onProxyMove(proxMove:String):void
{
playerNow=proxMove.substring(proxMove.indexOf("~")+1);
proxMove=proxMove.substring(0, proxMove.indexOf("~"));
if (playerNow=="player2" && !monitor[1])
{
playerText.setMove(playerNow);
p2move=proxMove;
monitor[1]=true;
}
//Check to see if both have moved
monitor[2]=(monitor[0] && monitor[1]);
if (monitor[2])
{
takeTurn( );
}
}
//
//doMove: Call server
//
public function doMove(m:String):void
{
nc.call("makeMove",null,m);
}
//
//takeTurn Complete the turn
//
public function takeTurn( ):void
{
rps=new RPS( );
rps.moveComplete(p1move,p2move,playerText,monitor);
rps.displayResults(oppText,p2move);
showText.setMove("ready");
}
//Get number connected
public function numConnect(cl:uint):void


Example 13-5. SymPlayer1.as (continued)

Free download pdf