public virtual void bubbleEvent(AsEvent _event) { AsVector <AsEventDispatcher> chain = null; AsDisplayObject element = this as AsDisplayObject; int length = 1; if (sBubbleChains.getLength() > 0) { chain = (AsVector <AsEventDispatcher>)(sBubbleChains.pop()); chain[0] = element; } else { chain = new AsVector <AsEventDispatcher>(); } while ((element = element.getParent()) != null) { chain[length++] = element; } int i = 0; for (; i < length; ++i) { bool stopPropagation = chain[i].invokeEvent(_event); if (stopPropagation) { break; } } chain.setLength(0); sBubbleChains.push(chain); }
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); } }
private AsVector <AsEventDispatcher> getBubbleChain(AsDisplayObject target, AsVector <AsEventDispatcher> result) { AsDisplayObject element = target; int length = 1; result.setLength(length); result[0] = target; while ((element = element.getParent()) != null) { result[length++] = element; } return(result); }
private void updateBubbleChain() { if (mTarget != null) { int length = 1; AsDisplayObject element = mTarget; mBubbleChain.setLength(0); mBubbleChain[0] = element; while ((element = element.getParent()) != null) { mBubbleChain[length++] = element; } } else { mBubbleChain.setLength(0); } }
public virtual AsMatrix getMatrix() { mMatrix = mDisplayObject.getTransformationMatrix(mDisplayObject.getParent(), mMatrix); return(mMatrix); }