dispatchEvent method

  1. @override
void dispatchEvent (Event event)
override

Dispatches the event to all listening subscribers.

Implementation

@override
void dispatchEvent(Event event) {
  List<EventDispatcher> ancestors = List<EventDispatcher>();

  for (DisplayObject p = this.parent; p != null; p = p.parent) {
    ancestors.add(p);
  }

  for (int i = ancestors.length - 1; i >= 0 && event.captures; i--) {
    ancestors[i].dispatchEventRaw(event, this, EventPhase.CAPTURING_PHASE);
    if (event.isPropagationStopped) return;
  }

  dispatchEventRaw(event, this, EventPhase.AT_TARGET);
  if (event.isPropagationStopped) return;

  for (int i = 0; i < ancestors.length && event.bubbles; i++) {
    ancestors[i].dispatchEventRaw(event, this, EventPhase.BUBBLING_PHASE);
    if (event.isPropagationStopped) return;
  }
}