Event
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Known subclasses: |
|
| Classpath: | org.asapframework.events.Event |
| File last modified: | Thursday, 13 July 2006, 13:48:48 |
Base class for dispatching events with EventDispatcher.
The EventDispatcher.dispatchEvent() expects an object with at least one property, 'type:String', which is the identifier of the event.
This is either the function that is called when the event is dispatched, or the link through Delegate to the function to be called.
Another (optional) property is 'target:Object', which is the source of the event.If this is left out, EventDispatcher puts the sending object in the property to ensure its presence and validity.
The base class contains these two properties as public properties, and a constructor to create an event fit for dispatching. As such, the class can be used to send events without any further information.
If more information must be sent, the class can be extended to contain more properties. The proposed pattern for the Event class and its subclasses is a ValueObject, with public properties.
The EventDispatcher.dispatchEvent() expects an object with at least one property, 'type:String', which is the identifier of the event.
This is either the function that is called when the event is dispatched, or the link through Delegate to the function to be called.
Another (optional) property is 'target:Object', which is the source of the event.If this is left out, EventDispatcher puts the sending object in the property to ensure its presence and validity.
The base class contains these two properties as public properties, and a constructor to create an event fit for dispatching. As such, the class can be used to send events without any further information.
If more information must be sent, the class can be extended to contain more properties. The proposed pattern for the Event class and its subclasses is a ValueObject, with public properties.
Example:
-
public static var EVENT_BUTTON_CLICKED:String = "onButtonClicked"; dispatchEvent(new Event(EVENT_BUTTON_CLICKED, this));
Summary
Constructor
Event
function Event (
inType:String,
inSource:Object)
Creates a new event with the name of the event handler and the source of the event.
Parameters:
inType :
String, name of event (and name of handler function when no Delegate is used)
inSource:
Object, (optional) source of event
Instance properties
target
target:Object
(read)
type
type:String
(read)