home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / smashout.swf / scripts / __Packages / Game / PongScoreboard.as < prev    next >
Encoding:
Text File  |  2005-11-09  |  4.8 KB  |  211 lines

  1. class Game.PongScoreboard extends MovieClip
  2. {
  3.    var quit_btn;
  4.    var pause_btn;
  5.    var help_btn;
  6.    var __score;
  7.    var score_txt;
  8.    var __level;
  9.    var level_txt;
  10.    var goalsLeft_txt;
  11.    var goalsRight_txt;
  12.    var itemLeft_mc;
  13.    var itemRight_mc;
  14.    var playerLeft_mc;
  15.    var playerRight_mc;
  16.    var dispatchEvent;
  17.    var __emptyScore = "";
  18.    static var __inited = false;
  19.    function PongScoreboard()
  20.    {
  21.       super();
  22.       if(!Game.PongScoreboard.__inited)
  23.       {
  24.          this.init();
  25.       }
  26.       this.resetGoals();
  27.       this.resetItems();
  28.       this.resetPlayers();
  29.       this.resetScore();
  30.       this.resetLevel();
  31.       var controller = this;
  32.       var quitEvent = "quit";
  33.       this.quit_btn.onPress = function()
  34.       {
  35.          controller.buttonRelease(quitEvent);
  36.       };
  37.       var pauseEvent = "pause";
  38.       this.pause_btn.onPress = function()
  39.       {
  40.          controller.buttonRelease(pauseEvent);
  41.       };
  42.       var helpEvent = "help";
  43.       this.help_btn.onPress = function()
  44.       {
  45.          controller.buttonRelease(helpEvent);
  46.       };
  47.    }
  48.    function set score(myScore)
  49.    {
  50.       if(myScore == undefined)
  51.       {
  52.          myScore = 0;
  53.       }
  54.       this.__score = myScore;
  55.       var _loc2_ = String(this.__score);
  56.       var _loc3_ = this.__emptyScore.length - _loc2_.length;
  57.       _loc2_ = this.__emptyScore.substr(0,_loc3_) + this.score;
  58.       this.score_txt.text = _loc2_;
  59.    }
  60.    function get score()
  61.    {
  62.       return this.__score;
  63.    }
  64.    function resetScore()
  65.    {
  66.       this.score = 0;
  67.    }
  68.    function set level(myLevel)
  69.    {
  70.       if(myLevel == undefined)
  71.       {
  72.          myLevel = 0;
  73.       }
  74.       this.__level = myLevel;
  75.       var _loc2_ = String(myLevel + 1);
  76.       if(_loc2_.length < 2)
  77.       {
  78.          _loc2_ = "0" + _loc2_;
  79.       }
  80.       this.level_txt.text = _loc2_;
  81.    }
  82.    function get level()
  83.    {
  84.       return this.__level;
  85.    }
  86.    function resetLevel()
  87.    {
  88.       this.level = 0;
  89.    }
  90.    function set goalsLeft(newGoals)
  91.    {
  92.       if(newGoals == undefined || newGoals < 0)
  93.       {
  94.          newGoals = 0;
  95.       }
  96.       else if(newGoals > 9)
  97.       {
  98.          newGoals = 9;
  99.       }
  100.       this.goalsLeft_txt.text = String(newGoals);
  101.    }
  102.    function get goalsLeft()
  103.    {
  104.       return Number(this.goalsLeft_txt.text);
  105.    }
  106.    function set goalsRight(newGoals)
  107.    {
  108.       if(newGoals == undefined || newGoals < 0)
  109.       {
  110.          newGoals = 0;
  111.       }
  112.       else if(newGoals > 9)
  113.       {
  114.          newGoals = 9;
  115.       }
  116.       this.goalsRight_txt.text = String(newGoals);
  117.    }
  118.    function get goalsRight()
  119.    {
  120.       return Number(this.goalsRight_txt.text);
  121.    }
  122.    function resetGoals()
  123.    {
  124.       this.goalsLeft = 0;
  125.       this.goalsRight = 0;
  126.    }
  127.    function set itemLeft(newItem)
  128.    {
  129.       if(newItem == undefined || newItem < 0)
  130.       {
  131.          newItem = 0;
  132.       }
  133.       else if(newItem > this.itemLeft_mc._totalframes - 1)
  134.       {
  135.          newItem = this.itemLeft_mc._totalframes - 1;
  136.       }
  137.       this.itemLeft_mc.gotoAndStop(newItem + 1);
  138.    }
  139.    function get itemLeft()
  140.    {
  141.       return this.itemLeft_mc._currentframe - 1;
  142.    }
  143.    function set itemRight(newItem)
  144.    {
  145.       if(newItem == undefined || newItem < 0)
  146.       {
  147.          newItem = 0;
  148.       }
  149.       else if(newItem > this.itemRight_mc._totalframes - 1)
  150.       {
  151.          newItem = this.itemRight_mc._totalframes - 1;
  152.       }
  153.       this.itemRight_mc.gotoAndStop(newItem + 1);
  154.    }
  155.    function get itemRight()
  156.    {
  157.       return this.itemRight_mc._currentframe - 1;
  158.    }
  159.    function resetItems()
  160.    {
  161.       this.itemLeft = 0;
  162.       this.itemRight = 0;
  163.    }
  164.    function set playerLeft(newItem)
  165.    {
  166.       if(newItem == undefined || newItem < 0)
  167.       {
  168.          newItem = 0;
  169.       }
  170.       else if(newItem > this.playerLeft_mc._totalframes - 1)
  171.       {
  172.          newItem = this.playerLeft_mc._totalframes - 1;
  173.       }
  174.       this.playerLeft_mc.gotoAndStop(newItem + 1);
  175.    }
  176.    function get playerLeft()
  177.    {
  178.       return this.playerLeft_mc._currentframe - 1;
  179.    }
  180.    function set playerRight(newItem)
  181.    {
  182.       if(newItem == undefined || newItem < 0)
  183.       {
  184.          newItem = 0;
  185.       }
  186.       else if(newItem > this.playerRight_mc._totalframes - 1)
  187.       {
  188.          newItem = this.playerRight_mc._totalframes - 1;
  189.       }
  190.       this.playerRight_mc.gotoAndStop(newItem + 1);
  191.    }
  192.    function get playerRight()
  193.    {
  194.       return this.playerRight_mc._currentframe - 1;
  195.    }
  196.    function resetPlayers()
  197.    {
  198.       this.playerLeft = 0;
  199.       this.playerRight = 5;
  200.    }
  201.    function buttonRelease(event)
  202.    {
  203.       this.dispatchEvent({type:"click",data:event});
  204.    }
  205.    function init()
  206.    {
  207.       mx.events.EventDispatcher.initialize(Game.PongScoreboard.prototype);
  208.       Game.PongScoreboard.__inited = true;
  209.    }
  210. }
  211.