Packagesekati.events
Classpublic final class ApplicationEventDispatcher

ApplicationEventDispatcher provides a central dispatching & eventing singleton target for API based applications. The purpose of having a centralized dispatcher is to standardized the grouping of like application event; meaning events created and utilized by your applications which do not originate from the API or the Flash / Flex frameworks.


Example
  var e : FormEvent ( FormEvent.USER_SUBMIT, {name:"sekati", phone:"+1.555.555.5555" confirm:true} ); // FormEvent inherits from sekati.events.ApplicationEvent.
  ApplicationEventDispatcher.$.dispatchEvent ( e );
  

See also

sekati.events.ApplicationEvent
flash.events.EventDispatcher


Public Properties
 PropertyDefined by
  $ : ApplicationEventDispatcher
[static][read-only] Shorthand singleton accessor getter
ApplicationEventDispatcher
Public Methods
 MethodDefined by
  
ApplicationEventDispatcher($:SingletonEnforcer = null, target:IEventDispatcher = null)
ApplicationEventDispatcher Singleton Constructor
ApplicationEventDispatcher
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true):void
Registers an ApplicationEvent listener with the ApplicationEventDispatcher singleton so that the listener receives notification of that ApplicationEvent (or ApplicationEvent descendent).
ApplicationEventDispatcher
  
Dispatches an ApplicationEvent into the event flow.
ApplicationEventDispatcher
  
[static] Singleton Accessor
ApplicationEventDispatcher
  
hasEventListener(type:String):Boolean
Checks whether the ApplicationEventDispatcher has any listeners registered for a specific type of event.
ApplicationEventDispatcher
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the ApplicationEventDispatcher singleton.
ApplicationEventDispatcher
  
willTrigger(type:String):Boolean
Checks whether an event listener is registered with this ApplicationEventDispatcher for the specified event type.
ApplicationEventDispatcher
Property detail
$property
$:ApplicationEventDispatcher  [read-only]

Shorthand singleton accessor getter

Implementation
    public static function get $():ApplicationEventDispatcher
Constructor detail
ApplicationEventDispatcher()constructor
public function ApplicationEventDispatcher($:SingletonEnforcer = null, target:IEventDispatcher = null)

ApplicationEventDispatcher Singleton Constructor

Parameters
$:SingletonEnforcer (default = null) — SingletonEnforcer - internal to the AS file; the param prevents external instantiation without error.
 
target:IEventDispatcher (default = null) — provides the internally wrapped IEventDispatcher
Method detail
addEventListener()method
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true):void

Registers an ApplicationEvent listener with the ApplicationEventDispatcher singleton so that the listener receives notification of that ApplicationEvent (or ApplicationEvent descendent).

When you no longer need an event listener, remove it by calling ApplicationEventDispatcher.$.removeEventListener() otherwise, memory problems might result. Objects with registered event listeners are not automatically removed from memory because the garbage collector does not remove objects that still have references.

Parameters
type:String — The type (name) of event.
 
listener:Function — The listener function that processes the event. This function must accept an ApplicationEvent object as its only parameter and must return nothing,
 
useCapture:Boolean (default = false) — Determines whether the listener works in the capture phase or the target and bubbling phases.
 
priority:int (default = 0) — The priority level of the event listener. Priorities are designated by a 32-bit integer.
 
useWeakReference:Boolean (default = true) — Determines whether the reference to the listener is strong or weak. A strong reference prevents your listener from being garbage-collected. A weak reference (the default) does not.

Example
e.g

dispatchEvent()method 
public function dispatchEvent(event:ApplicationEvent):Boolean

Dispatches an ApplicationEvent into the event flow. The event target is the ApplicationEventDispatcher singleton upon which dispatchEvent() is called.

Parameters
event:ApplicationEvent — The ApplicationEvent (or ApplicationEvent descendent) object dispatched into the event flow.

Returns
Boolean — Boolean A value of true unless preventDefault() is called on the event, in which case it returns false.
getInstance()method 
public static function getInstance():ApplicationEventDispatcher

Singleton Accessor

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

Checks whether the ApplicationEventDispatcher has any listeners registered for a specific type of event. This allows you to determine where ApplicationEventDispatcher 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 — The type of event.

Returns
Boolean — Boolean A value of true if a listener of the specified type is registered; otherwise false.

See also

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

Removes a listener from the ApplicationEventDispatcher singleton. If there is no matching listener registered with the ApplicationEventDispatcher a call to this method has no effect.

Parameters
type:String — The type of ApplicationEvent (or ApplicationEvent descendent).
 
listener:Function — The listener object to remove.
 
useCapture:Boolean (default = false) — Specifies whether the listener was registered for the capture phase or the target and bubbling phases.
willTrigger()method 
public function willTrigger(type:String):Boolean

Checks whether an event listener is registered with this ApplicationEventDispatcher 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 the ApplicationEventDispatcher.

Parameters
type:String — The type of event.

Returns
Boolean — Boolean A value of true if a listener of the specified type will be triggered; otherwise false.

See also