The EventDispatcher class is the base class for all classes that dispatch events. This is the Starling 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.

As in the conventional Flash classes, display objects inherit from EventDispatcher and can thus dispatch events. Beware, though, that the Starling event classes are not compatible with Flash events: Starling display objects dispatch Starling events, which will bubble along Starling display objects - but they cannot dispatch Flash events or bubble along Flash display objects.

@see Event @see starling.display.DisplayObject DisplayObject

### Hierarchy

- EventDispatcher
  - MeshStyle
  - Starling
  - Padding
  - FragmentFilter
  - DisplayObject
  - DelayedCall
  - Tween
  - TextFormat
  - TextOptions
  - AssetManager
  - AssetManager

## Index

### Constructors

- constructor

### Methods

- addEventListener
- dispatchEvent
- dispatchEventWith
- hasEventListener
- removeEventListener
- removeEventListeners

## Constructors

### constructor

- new EventDispatcher(): EventDispatcher

- - Defined in lib/starling/events/EventDispatcher.d.ts:27

  Creates an EventDispatcher.

  #### Returns EventDispatcher

## Methods

### addEventListener

- addEventListener(type: string, listener: Function): void

- - Defined in lib/starling/events/EventDispatcher.d.ts:32

  Registers an event listener at a certain object.

  #### Parameters

  - ##### type: string

  - ##### listener: Function

  #### Returns void

### dispatchEvent

- dispatchEvent(event: Event): void

- - Defined in lib/starling/events/EventDispatcher.d.ts:45

  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

  #### Returns void

### dispatchEventWith

- dispatchEventWith(type: string, bubbles?: boolean, data?: any): void

- - Defined in lib/starling/events/EventDispatcher.d.ts:50

  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

  - ##### Optional bubbles: boolean

  - ##### Optional data: any

  #### Returns void

### hasEventListener

- hasEventListener(type: string, listener?: any): boolean

- - Defined in lib/starling/events/EventDispatcher.d.ts:55

  If called with one argument, figures out if there are any listeners registered for the given event type. If called with two arguments, also determines if a specific listener is registered.

  #### Parameters

  - ##### type: string

  - ##### Optional listener: any

  #### Returns boolean

### removeEventListener

- removeEventListener(type: string, listener: Function): void

- - Defined in lib/starling/events/EventDispatcher.d.ts:35

  Removes an event listener from the object.

  #### Parameters

  - ##### type: string

  - ##### listener: Function

  #### Returns void

### removeEventListeners

- removeEventListeners(type?: string): void

- - Defined in lib/starling/events/EventDispatcher.d.ts:39

  Removes all event listeners with a certain type, or all of them if type is null. Be careful when removing all event listeners: you never know who else was listening.

  #### Parameters

  - ##### Optional type: string

  #### Returns void

Generated using TypeDoc