Package | com.asfusion.mate.events |
Class | public class Dispatcher |
Implements | ILoggerProvider, mx.core.IMXMLObject |
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 Syntax Hide MXML SyntaxThe <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
Property | Defined 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 |
Property | Defined 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 |
Method | Defined 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 |
Method | Defined 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 |
bubbles | property |
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
.
public function get bubbles():Boolean
public function set bubbles(value:Boolean):void
cancelable | property |
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
.
public function get cancelable():Boolean
public function set cancelable(value:Boolean):void
constructorArguments | property |
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
.
public function get constructorArguments():*
public function set constructorArguments(value:*):void
dispatcher | property |
protected var dispatcher:IEventDispatcher
Instance of the IEventDispatcher
that will be used to dispatch all the events.
document | property |
protected var document:Object
Internal storage for the document object.
eventProperties | property |
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.
public function get eventProperties():EventProperties
public function set eventProperties(value:EventProperties):void
generator | property |
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
.
public function get generator():Class
public function set generator(value:Class):void
logger | property |
protected var logger:IMateLogger
Instance of IMateLogger
used to debug.
responseDispatcher | property |
protected var responseDispatcher:IEventDispatcher
Instance of the IEventDispatcher
that will be used to dispatch all the reponses.
responseHandlers | property |
responseHandlers:Array
[read-write]
Array IResponseListeners
that are interested in listening to responses
after the event is dispatched.
public function get responseHandlers():Array
public function set responseHandlers(value:Array):void
type | property |
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
.
public function get type():String
public function set type(value:String):void
Dispatcher | () | constructor |
public function Dispatcher()
Constructor
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.
Parametersevent: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.
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.
Parametersevent:Event |
Boolean |
errorString | () | method |
public function errorString():String
Retuns the default error string to be used by the debugger.
ReturnsString |
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.
inlineProperties:Object (default = null )
|
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.
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.
Parametersdocument: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.
Parametersevent:Event |