Packagecom.asfusion.mate.events
Classpublic class Listener
Implementsflash.events.IEventDispatcher

Listener allows you to register a view as a listener for an event type. As long as the event bubbles up or is dispatched via the mate:Dispatcher tag or class, the registered listeners will be notified.



Public Properties
 PropertyDefined by
  method : Function
Specifies the method to call when an event is received.
Listener
  priority : int
(default = 0) — The priority level of the Listener.
Listener
  type : String
The type attribute specifies the event type you want to listen to.
Listener
  useWeakReference : Boolean
(default = true) — Determines whether the reference to the listener is strong or weak.
Listener
Protected Properties
 PropertyDefined by
  dispatcher : IEventDispatcher
Instance of an IEventDispatcher to which this listener will be subscribed.
Listener
  methodRegistered : Boolean
Flag to mark if a method has been registerd
Listener
  mxmlRegistered : Boolean
Flag to mark if an inline method has been registerd
Listener
  tagEventType : String
Type of event that this class dispatches.
Listener
Public Methods
 MethodDefined by
  
Constructor
Listener
  
addEventListener(eventType:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = true):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
Listener
  
dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow.
Listener
  
hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
Listener
  
removeEventListener(eventType:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
Listener
  
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.
Listener
Protected Methods
 MethodDefined by
  
updateListeners(newType:String, oldType:String = null):void
Updates the listeners when the type changes.
Listener
Events
 EventSummaryDefined by
   The event that gets dispatched when an event of the type specified in the type attribute is dispatched.Listener
Property detail
dispatcherproperty
protected var dispatcher:IEventDispatcher

Instance of an IEventDispatcher to which this listener will be subscribed.

methodproperty 
method:Function  [read-write]

Specifies the method to call when an event is received. Called method will automatically receive the event.

Implementation
    public function get method():Function
    public function set method(value:Function):void
methodRegisteredproperty 
protected var methodRegistered:Boolean

Flag to mark if a method has been registerd

mxmlRegisteredproperty 
protected var mxmlRegistered:Boolean

Flag to mark if an inline method has been registerd

priorityproperty 
priority:int  [read-write]

(default = 0) — The priority level of the Listener. 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.

The default value is 0.

Implementation
    public function get priority():int
    public function set priority(value:int):void
tagEventTypeproperty 
protected var tagEventType:String

Type of event that this class dispatches.

typeproperty 
type:String  [read-write]

The type attribute specifies the event type you want to listen to.

The default value is null.

Implementation
    public function get type():String
    public function set type(value:String):void
useWeakReferenceproperty 
useWeakReference:Boolean  [read-write]

(default = true) — Determines 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. When using modules, it is recomended to use weak references to garbage-collect unused modules

The default value is true.

Implementation
    public function get useWeakReference():Boolean
    public function set useWeakReference(value:Boolean):void
Constructor detail
Listener()constructor
public function Listener()

Constructor

Method detail
addEventListener()method
public function addEventListener(eventType:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = true):void

Registers an event listener object with an EventDispatcher object 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.

Parameters
eventType:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0.0)
 
useWeakReference:Boolean (default = true)
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.

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
removeEventListener()method 
public function removeEventListener(eventType: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
eventType:String
 
listener:Function
 
useCapture:Boolean (default = false)
updateListeners()method 
protected function updateListeners(newType:String, oldType:String = null):void

Updates the listeners when the type changes. This method unregisters the old values and registers the new values.

Parameters
newType:String
 
oldType:String (default = null)
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
Event detail
receiveevent 
Event object type: *

The event that gets dispatched when an event of the type specified in the type attribute is dispatched.