Revamped EZGame to work over the security boundary.
Now, instead of implementing "Game" and having the EZGame object assigned to you, you create it yourself using your top-level component. You must register listeners manually, and keyboard focus is currently an issue that I'm working on. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@137 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -20,12 +20,15 @@ import flash.text.TextFieldAutoSize;
|
||||
* free to copy/modify or extend this class.
|
||||
*/
|
||||
public class PlayersDisplay extends Sprite
|
||||
implements Game, StateChangedListener
|
||||
implements StateChangedListener
|
||||
{
|
||||
// implementation of Game method
|
||||
public function setGameObject (gameObj :EZGame) :void
|
||||
/**
|
||||
* Set the game control that will be used with this display.
|
||||
*/
|
||||
public function setGameControl (gameCtrl :EZGameControl) :void
|
||||
{
|
||||
_gameObj = gameObj;
|
||||
_gameCtrl = gameCtrl;
|
||||
_gameCtrl.registerListener(this);
|
||||
|
||||
configureInterface();
|
||||
}
|
||||
@@ -60,7 +63,7 @@ public class PlayersDisplay extends Sprite
|
||||
|
||||
// create a label for each player
|
||||
var playerIndex :int = 0;
|
||||
for each (var name :String in _gameObj.getPlayerNames()) {
|
||||
for each (var name :String in _gameCtrl.getPlayerNames()) {
|
||||
label = createPlayerLabel(playerIndex, name);
|
||||
icon = createPlayerIcon(playerIndex, name);
|
||||
var iconW :int = 0;
|
||||
@@ -156,15 +159,15 @@ public class PlayersDisplay extends Sprite
|
||||
*/
|
||||
protected function displayCurrentTurn () :void
|
||||
{
|
||||
var idx :int = _gameObj.isInPlay() ? _gameObj.getTurnHolderIndex() : -1;
|
||||
var idx :int = _gameCtrl.isInPlay() ? _gameCtrl.getTurnHolderIndex() : -1;
|
||||
for (var ii :int = 0; ii < _playerLabels.length; ii++) {
|
||||
var label :TextField = (_playerLabels[ii] as TextField);
|
||||
label.backgroundColor = getBackground(ii == idx);
|
||||
}
|
||||
}
|
||||
|
||||
/** Our game object. */
|
||||
protected var _gameObj :EZGame;
|
||||
/** Our game Control. */
|
||||
protected var _gameCtrl :EZGameControl;
|
||||
|
||||
/** An array of labels, one for each player name. */
|
||||
protected var _playerLabels :Array = [];
|
||||
|
||||
Reference in New Issue
Block a user