Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
class GameStateProxy extends Proxy implements IProxy { private var state:Object; public function GameStateProxy() { state.health = 10; } //shipIsHit() called by ShitHitCommand public function shipIsHit() { health--; if (health <= 0) sendNotification(GFacade.GAME_OVER); } public function get health():Number { return state.health; } public function set health(val:Number):void { state.health = val; }}
class ShipHitCommand extends SimpleCommand implements ICommand { override public function execute(note:INotification) { var gameStateProxy = facade.retrieve(GameStateProxy.NAME) as GameStateProxy; gameStateProxy.health--; if (gameStateProxy.health < 0) sendNotification(GAME_OVER); }}