Packagecom.asfusion.mate.events
Classpublic class Dispatcher
ImplementsILoggerProvider, mx.core.IMXMLObject

The Dispatcher can be used to dispatch an event from anywhere in your application. It can be used as a tag within your views and can be instantiated in ActionScript classes. Although views can dispatch events using their "dispatchEvent()" method, if these views as used within Popup windows, the event will not be received by other views or the EventMap. By using the Dispatcher, we can guarantee that the event will be received by all registered listeners.

Using the dispatcher as a tag allows you to dispatch an event from any MXML component. You can use the dispatcher attributes to make the dispatcher create the event for you or you can create an event and use the dispatcher only to dispatch the already created event.

It also allows you to receive direct responses such that only the object that dispatched the event receives this response.

MXML Syntaxexpanded Hide MXML Syntax

The <Dispatcher> tag has the following tag attributes:

  <Dispatcher
   Properties
  generator="Class"
  constructorArgs="Object|Array"
  eventProperties="EventProperties"
  type="String"
  bubbles="true|false"
  cancelable="true|false"
  responders="Array"
   />
  

Default MXML PropertyresponseHandlers

See also

com.asfusion.mate.responses.ServiceResponseHandler
com.asfusion.mate.responses.ResponseHandler


Public Properties
 PropertyDefined by
  bubbles : Boolean
Property of the event to create when using createAndDispatchEvent method.
Dispatcher
  cancelable : Boolean
Indicates whether the behavior associated with the event can be prevented.
Dispatcher
  constructorArguments : *
The constructorArgs allows you to pass an Object or an Array of objects to the contructor of the event when it is created by using the createAndDispatchEvent method.
Dispatcher
  eventProperties : EventProperties
eventProperties allows you to add properties to the event that will be created by the Dispatcher.
Dispatcher
  generator : Class
The generator attribute specifies what class should be used to instantiate the event when using the createAndDispatchEvent method.
Dispatcher
  responseHandlers : Array
Array IResponseListeners that are interested in listening to responses after the event is dispatched.
Dispatcher
  type : String
The type attribute specifies the event type you want to dispatch.
Dispatcher
Protected Properties
 PropertyDefined by
  dispatcher : IEventDispatcher
Instance of the IEventDispatcher that will be used to dispatch all the events.
Dispatcher
  document : Object
Internal storage for the document object.
Dispatcher
  logger : IMateLogger
Instance of IMateLogger used to debug.
Dispatcher
  responseDispatcher : IEventDispatcher
Instance of the IEventDispatcher that will be used to dispatch all the reponses.
Dispatcher
Public Methods
 MethodDefined by
  
Constructor
Dispatcher
  
dispatchEvent(event:Event):Boolean
Dispatches the given event into the event flow.
Dispatcher
  
errorString():String
Retuns the default error string to be used by the debugger.
Dispatcher
  
generateEvent(inlineProperties:Object = null):Boolean
Creates an event with the generator template and dispatches it into the event flow.
Dispatcher
  
getDocument():Object
A reference to the document object associated with this ILoggerProvider.
Dispatcher
  
initialized(document:Object, id:String):void
Called automatically by the MXML compiler if the IActionList is set up using a tag.
Dispatcher
  
removeReponders(event:Event):void
After a response is back, this method removes all the reponders for a specific event.
Dispatcher
Protected Methods
 MethodDefined by
  
addReponders(event:Event):void
Before dispatching the event, this method is called to add all the responders for that specific event.
Dispatcher
  
copyProperties(destination:*, properties:Object):void
Copies the properties from an Object of name-value pairs to the destination.
Dispatcher
Property detail
bubblesproperty
bubbles:Boolean  [read-write]

Property of the event to create when using createAndDispatchEvent method. Although you can specify the event's bubbles property, whether you set it to true or false will have little effect, as the event will be dispatched from the Mate Dispatcher itself (the Application by default).

The default value is false.

Implementation
    public function get bubbles():Boolean
    public function set bubbles(value:Boolean):void
cancelableproperty 
cancelable:Boolean  [read-write]

Indicates whether the behavior associated with the event can be prevented. Property of the event to create when using createAndDispatchEvent method.

The default value is true.

Implementation
    public function get cancelable():Boolean
    public function set cancelable(value:Boolean):void
constructorArgumentsproperty 
constructorArguments:*  [read-write]

The constructorArgs allows you to pass an Object or an Array of objects to the contructor of the event when it is created by using the createAndDispatchEvent method.

You can use an array to pass multiple arguments or use a simple Object if your signature has only one parameter.

The default value is undefined.

Implementation
    public function get constructorArguments():*
    public function set constructorArguments(value:*):void
dispatcherproperty 
protected var dispatcher:IEventDispatcher

Instance of the IEventDispatcher that will be used to dispatch all the events.

documentproperty 
protected var document:Object

Internal storage for the document object.

eventPropertiesproperty 
eventProperties:EventProperties  [read-write]

eventProperties allows you to add properties to the event that will be created by the Dispatcher.

These properties will be set before dispatched. These properties must be public.

The eventProperties property is usually specified by using the EventProperties tag.

Implementation
    public function get eventProperties():EventProperties
    public function set eventProperties(value:EventProperties):void
generatorproperty 
generator:Class  [read-write]

The generator attribute specifies what class should be used to instantiate the event when using the createAndDispatchEvent method.

The default value is null.

Implementation
    public function get generator():Class
    public function set generator(value:Class):void
loggerproperty 
protected var logger:IMateLogger

Instance of IMateLogger used to debug.

responseDispatcherproperty 
protected var responseDispatcher:IEventDispatcher

Instance of the IEventDispatcher that will be used to dispatch all the reponses.

responseHandlersproperty 
responseHandlers:Array  [read-write]

Array IResponseListeners that are interested in listening to responses after the event is dispatched.

Implementation
    public function get responseHandlers():Array
    public function set responseHandlers(value:Array):void
typeproperty 
type:String  [read-write]

The type attribute specifies the event type you want to dispatch. Property of the event to create when using createAndDispatchEvent method.

The default value is null.

Implementation
    public function get type():String
    public function set type(value:String):void
Constructor detail
Dispatcher()constructor
public function Dispatcher()

Constructor

Method detail
addReponders()method
protected function addReponders(event:Event):void

Before dispatching the event, this method is called to add all the responders for that specific event.

Parameters
event:Event
copyProperties()method 
protected function copyProperties(destination:*, properties:Object):void

Copies the properties from an Object of name-value pairs to the destination. The destination is the new event instance.

Parameters
destination:*
 
properties:Object
dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Dispatches the given event into the event flow. The event target is the EventDispatcher object. If bubble is false the default is the global mate dispatcher. If bubble is true wil try to use the document(parent) as a dispatcher.

Parameters
event:Event

Returns
Boolean
errorString()method 
public function errorString():String

Retuns the default error string to be used by the debugger.

Returns
String
generateEvent()method 
public function generateEvent(inlineProperties:Object = null):Boolean

Creates an event with the generator template and dispatches it into the event flow. All the eventProperties and the Object of name-value pairs passed in this method are copied to the new event before dispatching it.

Parameters
inlineProperties:Object (default = null)

Returns
Boolean
getDocument()method 
public function getDocument():Object

A reference to the document object associated with this ILoggerProvider. A document object is an Object at the top of the hierarchy of a Flex application, MXML component, or AS component.

Returns
Object
initialized()method 
public function initialized(document:Object, id:String):void

Called automatically by the MXML compiler if the IActionList is set up using a tag.

Parameters
document:Object
 
id:String
removeReponders()method 
public function removeReponders(event:Event):void

After a response is back, this method removes all the reponders for a specific event.

Parameters
event:Event