Packagecom.asfusion.mate.core
Classpublic class GlobalDispatcher
Implementsflash.events.IEventDispatcher

GlobalDispatcher is the default dispatcher that "Mate" uses. This class functions as a dual dispatcher because we can register to listen an event and we will be notified if the event is dispatched in the main application and in the SystemManager.

Because SystemManager is the parent of all the popup windows we can listen to events in that display list.



Public Properties
 PropertyDefined by
  applicationDispatcher : IEventDispatcher
[read-only] Returns the application itself as an event dispatcher.
GlobalDispatcher
  popupDispatcher : IEventDispatcher
[read-only] Returns the system manager as a dispatcher.
GlobalDispatcher
Public Methods
 MethodDefined by
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with this global EventDispatcher so that the listener receives notification of an event.
GlobalDispatcher
  
dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow.
GlobalDispatcher
  
hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
GlobalDispatcher
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
GlobalDispatcher
  
willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
GlobalDispatcher
Protected Methods
 MethodDefined by
  
interceptorEventHandler(event:Event):void
Every time that the popupDispatcher fires an event, this handler will be called.
GlobalDispatcher
Property detail
applicationDispatcherproperty
applicationDispatcher:IEventDispatcher  [read-only]

Returns the application itself as an event dispatcher.

Implementation
    public function get applicationDispatcher():IEventDispatcher
popupDispatcherproperty 
popupDispatcher:IEventDispatcher  [read-only]

Returns the system manager as a dispatcher. Usually, all the popups are created in this object. Having a reference to this object allows us listen to events on all popups windows.

Implementation
    public function get popupDispatcher():IEventDispatcher
Method detail
addEventListener()method
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Registers an event listener object with this global EventDispatcher so that the listener receives notification of an event. You can register event listeners on all nodes in the display list for a specific type of event, phase, and priority. We register to listen to events coming from the main application and the popup display list.

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)
dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Dispatches an event into the event flow. The event target is the EventDispatcher object upon which dispatchEvent() is called. We use the application as the dispatcher.

Parameters
event:Event

Returns
Boolean
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Checks whether the EventDispatcher object has any listeners registered for a specific type of event. This allows you to determine where an EventDispatcher object has altered handling of an event type in the event flow hierarchy. To determine whether a specific event type will actually trigger an event listener, use IEventDispatcher.willTrigger().

The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter.

Parameters
type:String

Returns
Boolean
interceptorEventHandler()method 
protected function interceptorEventHandler(event:Event):void

Every time that the popupDispatcher fires an event, this handler will be called. This handler will stop the event if the event is coming from the application display list. This happens because the SystemManager has the application itself as a child and also all the popups. We stop the propagation because we don't want to trigger the event twice.

Parameters
event:Event
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Removes a listener from the EventDispatcher object. If there is no matching listener registered with the EventDispatcher object, a call to this method has no effect.

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
willTrigger()method 
public function willTrigger(type:String):Boolean

Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. This method returns true if an event listener is triggered during any phase of the event flow when an event of the specified type is dispatched to this EventDispatcher object or any of its descendants.

The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter.

Parameters
type:String

Returns
Boolean