EventDispatcher
public class
loom2d.events.EventDispatcher
Description
The EventDispatcher class is the base class for all classes that dispatch events. This is the Loom version of the Flash class with the same name.
The event mechanism is a key feature of Starling's architecture. Objects can communicate with each other through events. Compared the the Flash event system, Starling's event system was simplified. The main difference is that Starling events have no "Capture" phase. They are simply dispatched at the target and may optionally bubble up. They cannot move in the opposite direction.
See also:
loom2d.events.Event
Loom.Display.DisplayObject DisplayObject
API overview
Constructor
EventDispatcher
()
Creates an EventDispatcher
Functions
Public functions
| addEventListener ( type: String , listener: Function ): Void |
Registers an event listener at a certain object |
| dispatchEvent ( event: Event ): Void |
Dispatches an event to all objects that have registered listeners for its type |
| dispatchEventWith ( type: String , bubbles: Boolean = false , data: Object = null ): Void |
Dispatches an event with the given parameters to all objects that have registered listeners for the given type |
| hasEventListener ( type: String ): Boolean |
Returns if there are listeners registered for a certain event type |
| removeEventListener ( type: String , listener: Function ): Void |
Removes an event listener from the object |
| removeEventListeners ( type: String = null ): Void |
Removes all event listeners with a certain type, or all of them if type is null |
Constructor
EventDispatcher ()
Creates an EventDispatcher.
Functions
addEventListener ( type: String , listener: Function ): Void
Registers an event listener at a certain object.
Parameters
| type: String | |
| listener: Function |
dispatchEvent ( event: Event ): Void
Dispatches an event to all objects that have registered listeners for its type. If an event with enabled 'bubble' property is dispatched to a display object, it will travel up along the line of parents, until it either hits the root object or someone stops its propagation manually.
Parameters
| event: Event |
dispatchEventWith ( type: String , bubbles: Boolean = false , data: Object = null ): Void
Dispatches an event with the given parameters to all objects that have registered listeners for the given type. The method uses an internal pool of event objects to avoid allocations.
Parameters
| type: String | |
| bubbles: Boolean = false | |
| data: Object = null |
getFullTypeName
(): String
Inherited from Object
native
Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.
Returns
| String | fully qualified type name of the Object. |
getType
(): Type
Inherited from Object
native
Gets the Type that describes the Object.
Returns
| Type | The Type that describes the object. |
getTypeName
(): String
Inherited from Object
native
Gets the type name of the Object.
Returns
| String | type name of the Object. |
hasEventListener ( type: String ): Boolean
Returns if there are listeners registered for a certain event type.
Parameters
| type: String |
removeEventListener ( type: String , listener: Function ): Void
Removes an event listener from the object.
Parameters
| type: String | |
| listener: Function |