home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / fscommand / linux / main.swf / scripts / __Packages / mx / events / EventDispatcher.as next >
Encoding:
Text File  |  2007-09-06  |  2.8 KB  |  98 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.       var _loc3_ = queue;
  10.       if(_loc3_ != undefined)
  11.       {
  12.          var l = _loc3_.length;
  13.          var _loc1_ = undefined;
  14.          _loc1_ = 0;
  15.          while(_loc1_ < l)
  16.          {
  17.             var _loc2_ = _loc3_[_loc1_];
  18.             if(_loc2_ == handler)
  19.             {
  20.                _loc3_.splice(_loc1_,1);
  21.                break;
  22.             }
  23.             _loc1_ = _loc1_ + 1;
  24.          }
  25.       }
  26.    }
  27.    static function initialize(object)
  28.    {
  29.       var _loc1_ = object;
  30.       if(mx.events.EventDispatcher._fEventDispatcher == undefined)
  31.       {
  32.          mx.events.EventDispatcher._fEventDispatcher = new mx.events.EventDispatcher();
  33.       }
  34.       _loc1_.addEventListener = mx.events.EventDispatcher._fEventDispatcher.addEventListener;
  35.       _loc1_.removeEventListener = mx.events.EventDispatcher._fEventDispatcher.removeEventListener;
  36.       _loc1_.dispatchEvent = mx.events.EventDispatcher._fEventDispatcher.dispatchEvent;
  37.       _loc1_.dispatchQueue = mx.events.EventDispatcher._fEventDispatcher.dispatchQueue;
  38.    }
  39.    function dispatchQueue(queueObj, eventObj)
  40.    {
  41.       var _loc2_ = eventObj;
  42.       var queueName = "__q_" + _loc2_.type;
  43.       var queue = queueObj[queueName];
  44.       if(queue != undefined)
  45.       {
  46.          var i;
  47.          for(i in queue)
  48.          {
  49.             var _loc1_ = queue[i];
  50.             var _loc3_ = typeof _loc1_;
  51.             if(_loc3_ == "object" || _loc3_ == "movieclip")
  52.             {
  53.                if(_loc1_.handleEvent == undefined)
  54.                {
  55.                   _loc1_[_loc2_.type](_loc2_);
  56.                }
  57.                else
  58.                {
  59.                   _loc1_.handleEvent(_loc2_);
  60.                }
  61.             }
  62.             else
  63.             {
  64.                _loc1_.apply(queueObj,[_loc2_]);
  65.             }
  66.          }
  67.       }
  68.    }
  69.    function dispatchEvent(eventObj)
  70.    {
  71.       var _loc1_ = eventObj;
  72.       var _loc2_ = this;
  73.       if(_loc1_.target == undefined)
  74.       {
  75.          _loc1_.target = _loc2_;
  76.       }
  77.       _loc2_[_loc1_.type + "Handler"](_loc1_);
  78.       _loc2_.dispatchQueue(_loc2_,_loc1_);
  79.    }
  80.    function addEventListener(event, handler)
  81.    {
  82.       var _loc2_ = this;
  83.       var _loc1_ = "__q_" + event;
  84.       if(_loc2_[_loc1_] == undefined)
  85.       {
  86.          _loc2_[_loc1_] = new Array();
  87.       }
  88.       _global.ASSetPropFlags(_loc2_,_loc1_,1);
  89.       mx.events.EventDispatcher._removeEventListener(_loc2_[_loc1_],event,handler);
  90.       _loc2_[_loc1_].push(handler);
  91.    }
  92.    function removeEventListener(event, handler)
  93.    {
  94.       var _loc1_ = "__q_" + event;
  95.       mx.events.EventDispatcher._removeEventListener(this[_loc1_],event,handler);
  96.    }
  97. }
  98.