home *** CD-ROM | disk | FTP | other *** search
- class Game.PongScoreboard extends MovieClip
- {
- var quit_btn;
- var pause_btn;
- var help_btn;
- var __score;
- var score_txt;
- var __level;
- var level_txt;
- var goalsLeft_txt;
- var goalsRight_txt;
- var itemLeft_mc;
- var itemRight_mc;
- var playerLeft_mc;
- var playerRight_mc;
- var dispatchEvent;
- var __emptyScore = "";
- static var __inited = false;
- function PongScoreboard()
- {
- super();
- if(!Game.PongScoreboard.__inited)
- {
- this.init();
- }
- this.resetGoals();
- this.resetItems();
- this.resetPlayers();
- this.resetScore();
- this.resetLevel();
- var controller = this;
- var quitEvent = "quit";
- this.quit_btn.onPress = function()
- {
- controller.buttonRelease(quitEvent);
- };
- var pauseEvent = "pause";
- this.pause_btn.onPress = function()
- {
- controller.buttonRelease(pauseEvent);
- };
- var helpEvent = "help";
- this.help_btn.onPress = function()
- {
- controller.buttonRelease(helpEvent);
- };
- }
- function set score(myScore)
- {
- if(myScore == undefined)
- {
- myScore = 0;
- }
- this.__score = myScore;
- var _loc2_ = String(this.__score);
- var _loc3_ = this.__emptyScore.length - _loc2_.length;
- _loc2_ = this.__emptyScore.substr(0,_loc3_) + this.score;
- this.score_txt.text = _loc2_;
- }
- function get score()
- {
- return this.__score;
- }
- function resetScore()
- {
- this.score = 0;
- }
- function set level(myLevel)
- {
- if(myLevel == undefined)
- {
- myLevel = 0;
- }
- this.__level = myLevel;
- var _loc2_ = String(myLevel + 1);
- if(_loc2_.length < 2)
- {
- _loc2_ = "0" + _loc2_;
- }
- this.level_txt.text = _loc2_;
- }
- function get level()
- {
- return this.__level;
- }
- function resetLevel()
- {
- this.level = 0;
- }
- function set goalsLeft(newGoals)
- {
- if(newGoals == undefined || newGoals < 0)
- {
- newGoals = 0;
- }
- else if(newGoals > 9)
- {
- newGoals = 9;
- }
- this.goalsLeft_txt.text = String(newGoals);
- }
- function get goalsLeft()
- {
- return Number(this.goalsLeft_txt.text);
- }
- function set goalsRight(newGoals)
- {
- if(newGoals == undefined || newGoals < 0)
- {
- newGoals = 0;
- }
- else if(newGoals > 9)
- {
- newGoals = 9;
- }
- this.goalsRight_txt.text = String(newGoals);
- }
- function get goalsRight()
- {
- return Number(this.goalsRight_txt.text);
- }
- function resetGoals()
- {
- this.goalsLeft = 0;
- this.goalsRight = 0;
- }
- function set itemLeft(newItem)
- {
- if(newItem == undefined || newItem < 0)
- {
- newItem = 0;
- }
- else if(newItem > this.itemLeft_mc._totalframes - 1)
- {
- newItem = this.itemLeft_mc._totalframes - 1;
- }
- this.itemLeft_mc.gotoAndStop(newItem + 1);
- }
- function get itemLeft()
- {
- return this.itemLeft_mc._currentframe - 1;
- }
- function set itemRight(newItem)
- {
- if(newItem == undefined || newItem < 0)
- {
- newItem = 0;
- }
- else if(newItem > this.itemRight_mc._totalframes - 1)
- {
- newItem = this.itemRight_mc._totalframes - 1;
- }
- this.itemRight_mc.gotoAndStop(newItem + 1);
- }
- function get itemRight()
- {
- return this.itemRight_mc._currentframe - 1;
- }
- function resetItems()
- {
- this.itemLeft = 0;
- this.itemRight = 0;
- }
- function set playerLeft(newItem)
- {
- if(newItem == undefined || newItem < 0)
- {
- newItem = 0;
- }
- else if(newItem > this.playerLeft_mc._totalframes - 1)
- {
- newItem = this.playerLeft_mc._totalframes - 1;
- }
- this.playerLeft_mc.gotoAndStop(newItem + 1);
- }
- function get playerLeft()
- {
- return this.playerLeft_mc._currentframe - 1;
- }
- function set playerRight(newItem)
- {
- if(newItem == undefined || newItem < 0)
- {
- newItem = 0;
- }
- else if(newItem > this.playerRight_mc._totalframes - 1)
- {
- newItem = this.playerRight_mc._totalframes - 1;
- }
- this.playerRight_mc.gotoAndStop(newItem + 1);
- }
- function get playerRight()
- {
- return this.playerRight_mc._currentframe - 1;
- }
- function resetPlayers()
- {
- this.playerLeft = 0;
- this.playerRight = 5;
- }
- function buttonRelease(event)
- {
- this.dispatchEvent({type:"click",data:event});
- }
- function init()
- {
- mx.events.EventDispatcher.initialize(Game.PongScoreboard.prototype);
- Game.PongScoreboard.__inited = true;
- }
- }
-