Description

The EventDispatcher class is the base class for all classes that dispatch events.

Methods

addEventListener(type, listener)

Description

The EventDispatcher class registers an event listener object with an EventDispatcher object to enable the listener receive notification about an event. The class does not check for duplicate listeners because the client handles the same.

Parameters

Name Type Description
type string The event type
listener function The callback function. This function must accept an Event object as its only parameter and must return nothing

Example

In this example, a listener for the ENTER_FRAME event is added to the stage.

function handlerFn(e) {
    console.log("I'm in handler " + e.getType());
}
		
var stage = player.getStage();
stage.addEventListener(flwebgl.events.Event.ENTER_FRAME, handlerFn);

dispatchEvent(event)

Description

This method dispatches an event to all objects that have registered listeners for its type.

Parameters

Name Type Description
event Event The event to dispatch

hasEventListener(type, listener)

Description

This method checks whether the EventDispatcher object has any listeners registered for a specific type of event.

Parameters

Name Type Description
type string The event type
listener
function
(Optional) If specified, check whether this listener has been added.
string
string
string

Returns

  • Type - boolean

removeEventListener(type, listener)

Description

    This method removes the event listener for the given event type.

Parameters

Name Type Description
type string The event type
listener function The listener to remove

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy