home *** CD-ROM | disk | FTP | other *** search
/ Hentai Interactivo 57 / HENTAI57.bin / flip3.swf / scripts / __Packages / mx / events / EventDispatcher.as next >
Text File  |  2008-11-04  |  3KB  |  96 lines

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