Flex - Event Dispatcher Class



  • The EventDispatcher class is the base class for all classes that dispatch events.

  • The EventDispatcher class implements the IEventDispatcher interface.

  • The EventDispatcher class allows any object on the display list to be an event target and as such, to use the methods of the IEventDispatcher interface.

In order to understand EventDispatcher, let us first look what are event and event targets.

What is an Event?

Event is a notification when a particular action is performed.For example, when a button is clicked then Click Event occurs.

What is an Event Target

The Event target serves as the focal point for how events flow through the display list hierarchy.

When an event occurs, Flash Player 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 divided into three phases:

S.N.Phase & Description
This phase comprises the journey from the root to the last node before the event target's node
This phase comprises only the event target node.
This phase comprises any subsequent nodes encountered on the return trip to the root of the display list.

In general, any class which extends EventDispatcher gets the event dispatching capability.

Class declaration

Following is the declaration for flash.events.EventDispatcher class:

public class EventDispatcher
   extends java.lang.Object
      implements IEventDispatcher 

Public methods

S.N.Method & Description
1EventDispatcher(target:IEventDispatcher = null)
Aggregates an instance of the EventDispatcher class.
2addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
Dispatches an event into the event flow.
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
5removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.


Following are the events for flash.events.EventDispatcher class:

S.N.Event & Description
Dispatched when the Flash Player gains operating system focus and becomes active.
Dispatched when the Flash Player loses operating system focus and becomes inactive.

Methods inherited

This class inherits methods from the following class:

  • Object