home *** CD-ROM | disk | FTP | other *** search
- class Game.PongLevelChooser extends MovieClip
- {
- var controller;
- var __enabled;
- var level_btn;
- var onRollOut;
- var onRollOver;
- var onDragOut;
- var onDragOver;
- var onRelease;
- var __currentBtn;
- var selected;
- var __level = 0;
- function PongLevelChooser()
- {
- super();
- this.setEnabled(this._visible);
- if(this.controller == undefined)
- {
- this.controller = this._parent;
- }
- }
- function setEnabled(flag)
- {
- this.__enabled = flag;
- this._visible = flag;
- if(flag)
- {
- this.initButton();
- }
- }
- function initChooseLevel()
- {
- var _loc2_ = 1;
- while(this.level_btn["level" + String(_loc2_) + "_mc"] != null)
- {
- this.initLevelButton(this.level_btn["level" + String(_loc2_) + "_mc"],_loc2_ - 1);
- _loc2_ = _loc2_ + 1;
- }
- this.selectLevel(this.level_btn.level1_mc,0);
- }
- function initButton()
- {
- var btnController = this;
- this.level_btn.onRollOver = this.level_btn.onDragOver = function()
- {
- this.gotoAndStop("over");
- };
- this.level_btn.onRollOut = this.level_btn.onDragOut = function()
- {
- this.gotoAndStop("up");
- };
- this.level_btn.onRelease = function()
- {
- delete this.onRollOut;
- delete this.onRollOver;
- delete this.onDragOut;
- delete this.onDragOver;
- delete this.onRelease;
- btnController.initChooseLevel();
- this.gotoAndStop("level");
- };
- }
- function selectLevel(btn, index)
- {
- this.__currentBtn.setSelected(false);
- this.__currentBtn = btn;
- btn.setSelected(true);
- this.__level = index;
- this.controller.startLevel = index;
- }
- function initLevelButton(btn, index)
- {
- var btnController = this;
- btn.onRollOver = btn.onDragOver = function()
- {
- if(!this.selected)
- {
- §§push(this.gotoAndStop("over"));
- }
- };
- btn.onRollOut = btn.onDragOut = function()
- {
- if(!this.selected)
- {
- §§push(this.gotoAndStop("up"));
- }
- };
- btn.onRelease = function()
- {
- btnController.selectLevel(this,index);
- };
- btn.setSelected = function(flag)
- {
- this.selected = flag;
- !!flag ? this.gotoAndStop("on") : this.gotoAndStop("up");
- };
- }
- }
-