Event targets are an important part of the Flash® Player and Adobe® AIR® event model. The event target serves as the focal point for how events flow through the display list hierarchy. When an event such as a mouse click or a keypress occurs, Flash Player or the AIR application dispatches an event object into the event flow from the root of the display list. The event object then makes its way through the display list until it reaches the event target, at which point it begins its return trip through the display list. This round-trip journey to the event target is conceptually divided into three phases: the capture phase comprises the journey from the root to the last node before the event target's node, the target phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the display list.
In general, the easiest way for a user-defined class to gain event dispatching capabilities is to extend EventDispatcher. If this is impossible(that is, if the class is already extending another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple hooks to route calls into the aggregated EventDispatcher.
targetThe target object for events dispatched to the EventDispatcher object. This parameter is used when the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher.
typeThe type of event.
useCaptureDetermines whether the listener works in the capture phase or the target and bubbling phases. If
useCaptureis set to
true, the listener processes the event only during the capture phase and not in the target or bubbling phase. If
false, the listener processes the event only during the target or bubbling phase. To listen for the event in all three phases, call
addEventListenertwice, once with
true, then again with
priorityThe priority level of the event listener. The priority is designated by a signed 32-bit integer. The higher the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. If two or more listeners share the same priority, they are processed in the order in which they were added. The default priority is 0.
useWeakReferenceDetermines whether the reference to the listener is strong or weak. A strong reference(the default) prevents your listener from being garbage-collected. A weak reference does not.
Class-level member functions are not subject to garbage collection, so you can set
true for class-level member functions without subjecting them to garbage collection. If you set
true for a listener that is a nested inner function, the function will be garbage-collected and no longer persistent. If you create references to the inner function(save it in another variable) then it is not garbage-collected and stays persistent.
listenerspecified is not a function.
eventThe Event object that is dispatched into the event flow. If the event is being redispatched, a clone of the event is created automatically. After an event is dispatched, its
targetproperty cannot be changed, so you must create a new copy of the event for redispatching to work.
trueif the event was successfully dispatched. A value of
falseindicates failure or that
preventDefault()was called on the event.
ErrorThe event dispatch recursion limit has been reached.
typeThe type of event.
useCaptureSpecifies whether the listener was registered for the capture phase or the target and bubbling phases. If the listener was registered for both the capture phase and the target and bubbling phases, two calls to
removeEventListener()are required to remove both, one call with
true, and another call with