Packagesystem.ioc
Classpublic class ObjectListener
InheritanceObjectListener Inheritance Object

This object defines a listener definition in an object definition.

Example :

     import system.ioc.ObjectListener ;
     
     var init:Array = 
     [
         { dispatcher:"dispatcher1" , type:"change" , method:"handleEvent" } ,
         { dispatcher:"dispatcher2" , type:"change" , method:"handleEvent" } 
     ] ;
     
     var listeners:Array = ObjectListener.create( init ) ;
     
     trace( listeners ) ; 
     
Usage, in the IoC factory we can use the "listeners" attribute in the object definition to defines the object like a listener.

Example :

     import system.ioc.ObjectFactory ;
     
     var context:Object =
     [
         { 
             id        : "dispatcher1" ,
             type      : "flash.events.EventDispatcher" ,
             singleton : true
         }
         ,
         { 
             id        : "dispatcher2" ,
             type      : "flash.events.EventDispatcher" ,
             singleton : true
         }
         ,    
         { 
             id        : "listener"   ,
             type      : "examples.Listener" ,
             singleton : true ,
             listeners :
             [
                 { dispatcher:"dispatcher1" , type:"change" , method:"handleEvent" , useCapture:false, priority:0 , useWeakReference:true } ,  
                 { dispatcher:"dispatcher2" , type:"change" } 
             ]
         }    
     ] ;
     
     var factory:ObjectFactory = new ObjectFactory() ;
     
     factory.create( context ) ; 
     
     // 1 - target the callback "handleEvent" method in the listener object (all objects with methods can be a listener)
     
     var dispatcher1:EventDispatcher = factory.getObject("dispatcher1") ;
     
     dispatcher1.dispatchEvent( new Event( "change" ) ) ; // [object Listener] handleEvent [Event type="change" bubbles=false cancelable=false eventPhase=2]
     
     // 2 - target the listener object if implements the system.events.EventListener interface.
     
     var dispatcher2:EventDispatcher = factory.getObject("dispatcher2") ;
     
     dispatcher2.dispatchEvent( new Event( "change" ) ) ; // [object Listener] handleEvent [Event type="change" bubbles=false cancelable=false eventPhase=2]
     
In the previous example we implement the examples.Listener class :
     package examples
     {
         import flash.events.Event;
         
         import system.events.EventListener;
          
         public class Listener implements EventListener
         {
             public function Listener()
             {
                  // constructor
             }
             
             public function handleEvent( e:Event ):void
             {
                 trace( this + " handleEvent " + e ) ;
             }
         }
     }
     



Public Properties
 PropertyDefined By
  dispatcher : String
The dispatcher expression reference of the listener.
ObjectListener
  method : String
The name of the method to invoke when the event is handle.
ObjectListener
  order : String
The order of the listener registration ('after' or by default 'before').
ObjectListener
  priority : int
Determines the priority level of the event listener.
ObjectListener
  type : String
The type name of the event dispatched by the dispatcher.
ObjectListener
  useCapture : Boolean
Determinates if the event flow use capture or not.
ObjectListener
  useWeakReference : Boolean
Indicates if the listener is a weak reference.
ObjectListener
Public Methods
 MethodDefined By
  
ObjectListener(dispatcher:String, type:String, method:String = null, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false, order:String = after)
Creates a new ObjectListener instance.
ObjectListener
  
toString():String
Returns the String representation of the object.
ObjectListener
Public Constants
 ConstantDefined By
  DISPATCHER : String = dispatcher
[static] Defines the "dispatcher" attribute in a listener object definition.
ObjectListener
  METHOD : String = method
[static] Defines the "method" attribute in a listener object definition.
ObjectListener
  ORDER : String = order
[static] Defines the "order" attribute in a listener object definition.
ObjectListener
  PRIORITY : String = priority
[static] Defines the "priority" attribute in a listener object definition.
ObjectListener
  TYPE : String = type
[static] Defines the "type" attribute in a listener object definition.
ObjectListener
  USE_CAPTURE : String = useCapture
[static] Defines the "useCapture" attribute in a listener object definition.
ObjectListener
  USE_WEAK_REFERENCE : String = useWeakReference
[static] Defines the "useWeakReference" attribute in a listener object definition.
ObjectListener
Property Detail
dispatcherproperty
public var dispatcher:String

The dispatcher expression reference of the listener.

methodproperty 
public var method:String

The name of the method to invoke when the event is handle.

orderproperty 
order:String

The order of the listener registration ('after' or by default 'before').


Implementation
    public function get order():String
    public function set order(value:String):void
priorityproperty 
public var priority:int

Determines the priority level of the event listener.

typeproperty 
public var type:String

The type name of the event dispatched by the dispatcher.

useCaptureproperty 
public var useCapture:Boolean

Determinates if the event flow use capture or not.

useWeakReferenceproperty 
public var useWeakReference:Boolean

Indicates if the listener is a weak reference.

Constructor Detail
ObjectListener()Constructor
public function ObjectListener(dispatcher:String, type:String, method:String = null, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false, order:String = after)

Creates a new ObjectListener instance.

Parameters
dispatcher:String — The dispatcher expression reference of the listener.
 
type:String — type name of the event dispatched by the dispatcher of this listener.
 
method:String (default = null) — The name of the method to invoke when the event is handle.
 
useCapture:Boolean (default = false) — Determinates if the event flow use capture or not.
 
priority:int (default = 0) — Determines the priority level of the event listener.
 
useWeakReference:Boolean (default = false) — Indicates if the listener is a weak reference.
 
order:String (default = after) — Indicates the order to register the listener "after" or "before" (see the system.ioc.ObjectOrder enumeration class).
Method Detail
toString()method
public function toString():String

Returns the String representation of the object.

Returns
String — the String representation of the object.
Constant Detail
DISPATCHERConstant
public static const DISPATCHER:String = dispatcher

Defines the "dispatcher" attribute in a listener object definition.

METHODConstant 
public static const METHOD:String = method

Defines the "method" attribute in a listener object definition.

ORDERConstant 
public static const ORDER:String = order

Defines the "order" attribute in a listener object definition.

PRIORITYConstant 
public static const PRIORITY:String = priority

Defines the "priority" attribute in a listener object definition.

TYPEConstant 
public static const TYPE:String = type

Defines the "type" attribute in a listener object definition.

USE_CAPTUREConstant 
public static const USE_CAPTURE:String = useCapture

Defines the "useCapture" attribute in a listener object definition.

USE_WEAK_REFERENCEConstant 
public static const USE_WEAK_REFERENCE:String = useWeakReference

Defines the "useWeakReference" attribute in a listener object definition.