Пример #1
0
        public virtual void dispatchEvent(AsEvent _event)
        {
            AsVector <AsEventListenerCallback> listeners = (AsVector <AsEventListenerCallback>)(mEventListeners != null ? mEventListeners[_event.getType()] : null);

            if (listeners == null && !_event.getBubbles())
            {
                return;
            }
            AsEventDispatcher previousTarget = _event.getTarget();

            if (previousTarget == null || _event.getCurrentTarget() != null)
            {
                _event.setTarget(this);
            }
            bool stopImmediatePropagation = false;
            uint numListeners             = (uint)(listeners == null ? 0 : listeners.getLength());

            if (numListeners != 0)
            {
                _event.setCurrentTarget(this);
                int i = 0;
                for (; i < numListeners; ++i)
                {
                    AsEventListenerCallback listener = listeners[i];
                    listener(_event);
                    if (_event.getStopsImmediatePropagation())
                    {
                        stopImmediatePropagation = true;
                        break;
                    }
                }
            }
            if (!stopImmediatePropagation && _event.getBubbles() && !_event.getStopsPropagation() && this is AsDisplayObject)
            {
                AsDisplayObject targetDisplayObject = this as AsDisplayObject;
                if (targetDisplayObject.getParent() != null)
                {
                    _event.setCurrentTarget(null);
                    targetDisplayObject.getParent().dispatchEvent(_event);
                }
            }
            if (previousTarget != null)
            {
                _event.setTarget(previousTarget);
            }
        }
 public virtual void dispatchEvent(AsEvent _event)
 {
     AsVector<AsEventListenerCallback> listeners = (AsVector<AsEventListenerCallback>)(((mEventListeners != null) ? (mEventListeners[_event.getType()]) : (null)));
     if(((listeners == null) && !(_event.getBubbles())))
     {
         return;
     }
     AsEventDispatcher previousTarget = _event.getTarget();
     if(((previousTarget == null) || (_event.getCurrentTarget() != null)))
     {
         _event.setTarget(this);
     }
     bool stopImmediatePropagation = false;
     uint numListeners = (uint)((((listeners == null)) ? (0) : (listeners.getLength())));
     if((numListeners != 0))
     {
         _event.setCurrentTarget(this);
         int i = 0;
         for (; (i < numListeners); ++i)
         {
             AsEventListenerCallback listener = listeners[i];
             listener(_event);
             if(_event.getStopsImmediatePropagation())
             {
                 stopImmediatePropagation = true;
                 break;
             }
         }
     }
     if((((!(stopImmediatePropagation) && _event.getBubbles()) && !(_event.getStopsPropagation())) && this is AsDisplayObject))
     {
         AsDisplayObject targetDisplayObject = ((this is AsDisplayObject) ? ((AsDisplayObject)(this)) : null);
         if((targetDisplayObject.getParent() != null))
         {
             _event.setCurrentTarget(null);
             targetDisplayObject.getParent().dispatchEvent(_event);
         }
     }
     if(previousTarget != null)
     {
         _event.setTarget(previousTarget);
     }
 }
 public virtual void dispatchEvent(AsEvent _event)
 {
     AsVector<AsEventListenerCallback> listeners = (AsVector<AsEventListenerCallback>)(mEventListeners != null ? mEventListeners[_event.getType()] : null);
     if(listeners == null && !_event.getBubbles())
     {
         return;
     }
     AsEventDispatcher previousTarget = _event.getTarget();
     if(previousTarget == null || _event.getCurrentTarget() != null)
     {
         _event.setTarget(this);
     }
     bool stopImmediatePropagation = false;
     uint numListeners = (uint)(listeners == null ? 0 : listeners.getLength());
     if(numListeners != 0)
     {
         _event.setCurrentTarget(this);
         int i = 0;
         for (; i < numListeners; ++i)
         {
             AsEventListenerCallback listener = listeners[i];
             listener(_event);
             if(_event.getStopsImmediatePropagation())
             {
                 stopImmediatePropagation = true;
                 break;
             }
         }
     }
     if(!stopImmediatePropagation && _event.getBubbles() && !_event.getStopsPropagation() && this is AsDisplayObject)
     {
         AsDisplayObject targetDisplayObject = this as AsDisplayObject;
         if(targetDisplayObject.getParent() != null)
         {
             _event.setCurrentTarget(null);
             targetDisplayObject.getParent().dispatchEvent(_event);
         }
     }
     if(previousTarget != null)
     {
         _event.setTarget(previousTarget);
     }
 }