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

  1. class Game.PongLevelChooser extends MovieClip
  2. {
  3.    var controller;
  4.    var __enabled;
  5.    var level_btn;
  6.    var onRollOut;
  7.    var onRollOver;
  8.    var onDragOut;
  9.    var onDragOver;
  10.    var onRelease;
  11.    var __currentBtn;
  12.    var selected;
  13.    var __level = 0;
  14.    function PongLevelChooser()
  15.    {
  16.       super();
  17.       this.setEnabled(this._visible);
  18.       if(this.controller == undefined)
  19.       {
  20.          this.controller = this._parent;
  21.       }
  22.    }
  23.    function setEnabled(flag)
  24.    {
  25.       this.__enabled = flag;
  26.       this._visible = flag;
  27.       if(flag)
  28.       {
  29.          this.initButton();
  30.       }
  31.    }
  32.    function initChooseLevel()
  33.    {
  34.       var _loc2_ = 1;
  35.       while(this.level_btn["level" + String(_loc2_) + "_mc"] != null)
  36.       {
  37.          this.initLevelButton(this.level_btn["level" + String(_loc2_) + "_mc"],_loc2_ - 1);
  38.          _loc2_ = _loc2_ + 1;
  39.       }
  40.       this.selectLevel(this.level_btn.level1_mc,0);
  41.    }
  42.    function initButton()
  43.    {
  44.       var btnController = this;
  45.       this.level_btn.onRollOver = this.level_btn.onDragOver = function()
  46.       {
  47.          this.gotoAndStop("over");
  48.       };
  49.       this.level_btn.onRollOut = this.level_btn.onDragOut = function()
  50.       {
  51.          this.gotoAndStop("up");
  52.       };
  53.       this.level_btn.onRelease = function()
  54.       {
  55.          delete this.onRollOut;
  56.          delete this.onRollOver;
  57.          delete this.onDragOut;
  58.          delete this.onDragOver;
  59.          delete this.onRelease;
  60.          btnController.initChooseLevel();
  61.          this.gotoAndStop("level");
  62.       };
  63.    }
  64.    function selectLevel(btn, index)
  65.    {
  66.       this.__currentBtn.setSelected(false);
  67.       this.__currentBtn = btn;
  68.       btn.setSelected(true);
  69.       this.__level = index;
  70.       this.controller.startLevel = index;
  71.    }
  72.    function initLevelButton(btn, index)
  73.    {
  74.       var btnController = this;
  75.       btn.onRollOver = btn.onDragOver = function()
  76.       {
  77.          if(!this.selected)
  78.          {
  79.             ┬º┬ºpush(this.gotoAndStop("over"));
  80.          }
  81.       };
  82.       btn.onRollOut = btn.onDragOut = function()
  83.       {
  84.          if(!this.selected)
  85.          {
  86.             ┬º┬ºpush(this.gotoAndStop("up"));
  87.          }
  88.       };
  89.       btn.onRelease = function()
  90.       {
  91.          btnController.selectLevel(this,index);
  92.       };
  93.       btn.setSelected = function(flag)
  94.       {
  95.          this.selected = flag;
  96.          !!flag ? this.gotoAndStop("on") : this.gotoAndStop("up");
  97.       };
  98.    }
  99. }
  100.