Packagesystem.events
Classpublic class FrontController
InheritanceFrontController Inheritance Object

The front controller pattern defines a single EventDispatcher that is responsible for processing application requests.

A front controller centralizes functions such as view selection, security, and templating, and applies them consistently across all pages or views. Consequently, when the behavior of these functions need to change, only a small part of the application needs to be changed: the controller and its helper classes.



Public Methods
 MethodDefined By
  
FrontController(channel:String = null, target:EventDispatcher = null)
Creates a new FrontController instance.
FrontController
  
add(type:String, listener:*):void
Add a new entry into the FrontController.
FrontController
  
addBatch(type:String, listener:EventListener = null):void
Adds a new EventListener into an EventListenerBatch in the FrontController.
FrontController
  
clear():void
Removes all entries in the FrontController.
FrontController
  
contains(type:String):Boolean
Returns true if the specified type is registered in the FrontController.
FrontController
  
containsInstance(channel:String):Boolean
[static] Indicates if the specified singleton reference is register.
FrontController
  
fireEvent(event:*):void
Dispatch an event into the FrontController
FrontController
  
flush():void
[static] Flush all global FrontController singletons.
FrontController
  
getChannels():Array
[static] Returns the Array representation of all channels register in the FrontController factory or null if no singletons are registered.
FrontController
  
Returns the internal EventDispatcher singleton reference of this FrontController.
FrontController
  
getInstance(channel:String = null):FrontController
[static] Returns a global FrontController singleton.
FrontController
  
getListener(type:String):*
Returns the listener register in the frontcontroller with the specified event name.
FrontController
  
isEventListenerBatch(type:String):Boolean
Indicates if the specified EventListener registered with the specified type in argument is an EventListenerBatch instance.
FrontController
  
remove(eventName:String):void
Remove an entry into the FrontController.
FrontController
  
removeInstance(channel:String = null):Boolean
[static] Removes a global FrontController singleton.
FrontController
  
Sets the EventDispatcher reference of this FrontController.
FrontController
  
size():int
Returns the number of elements in the controller.
FrontController
Constructor Detail
FrontController()Constructor
public function FrontController(channel:String = null, target:EventDispatcher = null)

Creates a new FrontController instance.

Parameters
channel:String (default = null) — the channel of this FrontController.
 
target:EventDispatcher (default = null) — the EventDispatcher reference to switch with the default EventDispatcher singleton in the controller.

Example :

         var controller:FrontController = new FrontController() ;
         
Method Detail
add()method
public function add(type:String, listener:*):void

Add a new entry into the FrontController.

Parameters

type:String — The type used to register the specified listener.
 
listener:* — A listener Function or an EventListener object.


Throws
ArgumentError — If the 'type' value in argument is null or undefined.
 
ArgumentError — If the 'listener' object in argument is null or undefined.
addBatch()method 
public function addBatch(type:String, listener:EventListener = null):void

Adds a new EventListener into an EventListenerBatch in the FrontController. If this listener argument is null' and if the eventName argument isn't register with an EventListenerBatch in the FrontController, an empty EventListenerBatch is created and register in the FrontController with the specified 'eventName'.

Parameters

type:String — The type to register the specified listener.
 
listener:EventListener (default = null) — (optional) The EventListener mapped in the FrontController with the specified event type (This listener is added in an EventListenerBatch).


Throws
ArgumentError — If the 'type' argument not must be null.
clear()method 
public function clear():void

Removes all entries in the FrontController.

contains()method 
public function contains(type:String):Boolean

Returns true if the specified type is registered in the FrontController.

Parameters

type:String — The search type value.

Returns
Booleantrue if the specified type is registered in the FrontController.
containsInstance()method 
public static function containsInstance(channel:String):Boolean

Indicates if the specified singleton reference is register.

Parameters

channel:String — the channel value of the singleton reference register in the factory.

Returns
Booleantrue If the specified singleton reference is register.
fireEvent()method 
public function fireEvent(event:*):void

Dispatch an event into the FrontController

Parameters

event:* — A type value who corresponding a event type or an event object.


Throws
ArgumentError — If the passed-in 'event' argument is not a String or an Event object.
flush()method 
public static function flush():void

Flush all global FrontController singletons.

getChannels()method 
public static function getChannels():Array

Returns the Array representation of all channels register in the FrontController factory or null if no singletons are registered.

Returns
Array — the Array representation of all channels register in the FrontController factory or null if no singletons are registered.
getEventDispatcher()method 
public function getEventDispatcher():EventDispatcher

Returns the internal EventDispatcher singleton reference of this FrontController.

Returns
EventDispatcher — the internal EventDispatcher singleton reference of this FrontController.
getInstance()method 
public static function getInstance(channel:String = null):FrontController

Returns a global FrontController singleton.

Parameters

channel:String (default = null) — The channel of the FrontController (default the EventDispatcher.DEFAULT_SINGLETON_NAME value).

Returns
FrontController — a global FrontController singleton.
getListener()method 
public function getListener(type:String):*

Returns the listener register in the frontcontroller with the specified event name.

Parameters

type:String — The type of the listener register.

Returns
* — an EventListener or a event callback Function.
isEventListenerBatch()method 
public function isEventListenerBatch(type:String):Boolean

Indicates if the specified EventListener registered with the specified type in argument is an EventListenerBatch instance.

Parameters

type:String — The type to indicates if an EventListenerBatch is registered.

Returns
Booleantrue if the specified EventListener or listener function registered with the 'eventName' value in argument is an EventListenerBatch instance.
remove()method 
public function remove(eventName:String):void

Remove an entry into the FrontController.

Parameters

eventName:String — The name of the event type.

removeInstance()method 
public static function removeInstance(channel:String = null):Boolean

Removes a global FrontController singleton.

Parameters

channel:String (default = null) — The channel of the FrontController to remove.

Returns
Booleantrue if a singleton is removed with the specified channel.
setEventDispatcher()method 
public function setEventDispatcher(target:EventDispatcher):void

Sets the EventDispatcher reference of this FrontController.

Parameters

target:EventDispatcher — The EventDispatcher reference of this FrontController.

size()method 
public function size():int

Returns the number of elements in the controller.

Returns
int — the number of elements in the controller.