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

  1. class Game.PongModal extends MovieClip
  2. {
  3.    var bg_mc;
  4.    var keyListener;
  5.    var dispatchEvent;
  6.    var close_btn;
  7.    var base_mc;
  8.    static var backgroundID = "ModalBackground";
  9.    static var LOWEST_DEPTH = -16384;
  10.    var screenName = "modal";
  11.    var __backgroundAlpha = 60;
  12.    static var __inited = false;
  13.    function PongModal()
  14.    {
  15.       super();
  16.       if(!Game.PongModal.__inited)
  17.       {
  18.          this.init();
  19.       }
  20.       this.createBackground();
  21.       this.initCloseButton();
  22.    }
  23.    function set backgroundAlpha(newAlpha)
  24.    {
  25.       this.__backgroundAlpha = newAlpha;
  26.       this.bg_mc._alpha = newAlpha;
  27.    }
  28.    function get backgroundAlpha()
  29.    {
  30.       return this.__backgroundAlpha;
  31.    }
  32.    function close()
  33.    {
  34.       Key.removeListener(this.keyListener);
  35.       this.dispatchEvent({type:"closeModal",name:this.screenName});
  36.       this.removeMovieClip();
  37.    }
  38.    function init()
  39.    {
  40.       mx.events.EventDispatcher.initialize(Game.PongModal.prototype);
  41.       Game.PongModal.__inited = true;
  42.    }
  43.    function initCloseButton(myClose_btn)
  44.    {
  45.       if(!myClose_btn)
  46.       {
  47.          if(!this.close_btn)
  48.          {
  49.             if(!this.base_mc.close_btn)
  50.             {
  51.                return undefined;
  52.             }
  53.             this.close_btn = this.base_mc.close_btn;
  54.          }
  55.          myClose_btn = this.close_btn;
  56.       }
  57.       var controller = this;
  58.       myClose_btn.onRelease = function()
  59.       {
  60.          controller.close();
  61.       };
  62.    }
  63.    function createBackground()
  64.    {
  65.       if(!this.bg_mc)
  66.       {
  67.          this.bg_mc = this.attachMovie(Game.PongModal.backgroundID,"bg_mc",Game.PongModal.LOWEST_DEPTH);
  68.       }
  69.       this.bg_mc._width = Stage.width;
  70.       this.bg_mc._height = Stage.height;
  71.       this.bg_mc._alpha = this.backgroundAlpha;
  72.       this.bg_mc.useHandCursor = false;
  73.       this.bg_mc.onRelease = function()
  74.       {
  75.       };
  76.    }
  77. }
  78.