home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / shell.swf / scripts / __Packages / mx / events / EventDispatcher.as next >
Text File  |  2007-10-16  |  3KB  |  102 lines

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