10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example 13-5. SymPlayer1.as (continued)<br />

playerText.setMove("player1");<br />

if (!monitor[0])<br />

{<br />

p1move=locMove;<br />

monitor[0]=true;<br />

}<br />

//Check to see if both have moved<br />

monitor[2]=(monitor[0] && monitor[1]);<br />

if (monitor[2])<br />

{<br />

takeTurn( );<br />

}<br />

}<br />

//<br />

//onProxyMove: Info from server<br />

//<br />

public function onProxyMove(proxMove:String):void<br />

{<br />

playerNow=proxMove.substring(proxMove.indexOf("~")+1);<br />

proxMove=proxMove.substring(0, proxMove.indexOf("~"));<br />

if (playerNow=="player2" && !monitor[1])<br />

{<br />

playerText.setMove(playerNow);<br />

p2move=proxMove;<br />

monitor[1]=true;<br />

}<br />

//Check to see if both have moved<br />

monitor[2]=(monitor[0] && monitor[1]);<br />

if (monitor[2])<br />

{<br />

takeTurn( );<br />

}<br />

}<br />

//<br />

//doMove: Call server<br />

//<br />

public function doMove(m:String):void<br />

{<br />

nc.call("makeMove",null,m);<br />

}<br />

//<br />

//takeTurn Complete the turn<br />

//<br />

public function takeTurn( ):void<br />

{<br />

rps=new RPS( );<br />

rps.moveComplete(p1move,p2move,playerText,monitor);<br />

rps.displayResults(oppText,p2move);<br />

showText.setMove("ready");<br />

}<br />

//Get number connected<br />

public function numConnect(cl:uint):void<br />

Player-Proxy Classes | 489

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!