home *** CD-ROM | disk | FTP | other *** search
/ Champak 112 / jogo-disk-112.iso / Games / pixieland_puzzle.swf / scripts / __Packages / mx / events / EventDispatcher.as next >
Text File  |  2010-07-14  |  3KB  |  92 lines

  1. class mx.events.EventDispatcher
  2. {
  3.    static var _fEventDispatcher = undefined;
  4.    function EventDispatcher()
  5.    {
  6.    }
  7.    static function _removeEventListener(queue, event, handler)
  8.    {
  9.       if(queue != undefined)
  10.       {
  11.          var _loc4_ = queue.length;
  12.          var _loc1_ = undefined;
  13.          _loc1_ = 0;
  14.          while(_loc1_ < _loc4_)
  15.          {
  16.             var _loc2_ = queue[_loc1_];
  17.             if(_loc2_ == handler)
  18.             {
  19.                queue.splice(_loc1_,1);
  20.                return undefined;
  21.             }
  22.             _loc1_ = _loc1_ + 1;
  23.          }
  24.       }
  25.    }
  26.    static function initialize(object)
  27.    {
  28.       if(mx.events.EventDispatcher._fEventDispatcher == undefined)
  29.       {
  30.          mx.events.EventDispatcher._fEventDispatcher = new mx.events.EventDispatcher();
  31.       }
  32.       object.addEventListener = mx.events.EventDispatcher._fEventDispatcher.addEventListener;
  33.       object.removeEventListener = mx.events.EventDispatcher._fEventDispatcher.removeEventListener;
  34.       object.dispatchEvent = mx.events.EventDispatcher._fEventDispatcher.dispatchEvent;
  35.       object.dispatchQueue = mx.events.EventDispatcher._fEventDispatcher.dispatchQueue;
  36.    }
  37.    function dispatchQueue(queueObj, eventObj)
  38.    {
  39.       var _loc7_ = "__q_" + eventObj.type;
  40.       var _loc4_ = queueObj[_loc7_];
  41.       if(_loc4_ != undefined)
  42.       {
  43.          var _loc5_ = undefined;
  44.          for(_loc5_ in _loc4_)
  45.          {
  46.             var _loc1_ = _loc4_[_loc5_];
  47.             var _loc3_ = typeof _loc1_;
  48.             if(_loc3_ == "object" || _loc3_ == "movieclip")
  49.             {
  50.                if(_loc1_.handleEvent == undefined)
  51.                {
  52.                   _loc1_[eventObj.type](eventObj);
  53.                }
  54.                else
  55.                {
  56.                   _loc1_.handleEvent(eventObj);
  57.                }
  58.             }
  59.             else
  60.             {
  61.                _loc1_.apply(queueObj,[eventObj]);
  62.             }
  63.          }
  64.       }
  65.    }
  66.    function dispatchEvent(eventObj)
  67.    {
  68.       if(eventObj.target == undefined)
  69.       {
  70.          eventObj.target = this;
  71.       }
  72.       this[eventObj.type + "Handler"](eventObj);
  73.       this.dispatchQueue(this,eventObj);
  74.    }
  75.    function addEventListener(event, handler)
  76.    {
  77.       var _loc3_ = "__q_" + event;
  78.       if(this[_loc3_] == undefined)
  79.       {
  80.          this[_loc3_] = new Array();
  81.       }
  82.       _global.ASSetPropFlags(this,_loc3_,1);
  83.       mx.events.EventDispatcher._removeEventListener(this[_loc3_],event,handler);
  84.       this[_loc3_].push(handler);
  85.    }
  86.    function removeEventListener(event, handler)
  87.    {
  88.       var _loc2_ = "__q_" + event;
  89.       mx.events.EventDispatcher._removeEventListener(this[_loc2_],event,handler);
  90.    }
  91. }
  92.