Class createjs.EventDispatcher
Extends
.
Defined in: event_dispatcher.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A class that can receive events and dispatch events.
|
Field Attributes | Field Name and Description |
---|---|
<static> |
createjs.EventDispatcher.AT_TARGET
Representing this dispatcher is in the target phase.
|
<static> |
createjs.EventDispatcher.BUBBLING_PHASE
Representing this dispatcher is in the bubbling phase.
|
<static> |
createjs.EventDispatcher.CAPTURE_PHASE
Representing this dispatcher is in the capture phase.
|
<static> |
createjs.EventDispatcher.CLICK
The event ID of the 'click' event.
|
<static> |
createjs.EventDispatcher.MOUSE_DOWN
The event ID of the 'mousedown' event.
|
<static> |
createjs.EventDispatcher.PRESS_MOVE
The event ID of the 'pressmove' event.
|
<static> |
createjs.EventDispatcher.PRESS_UP
The event ID of the 'pressup' event.
|
Method Attributes | Method Name and Description |
---|---|
addListener(type, listener, opt_useCapture)
Adds the specified event listener.
|
|
contains(child)
Returns whether the specified object is either this container or its
descendant.
|
|
dispatch(value, opt_target)
Dispatches the specified event to all listeners.
|
|
dispatchNotification(type)
Dispatches a notification event, which consists only of a type name.
|
|
dispatchRawEvent(event)
Dispatches a createjs.Event object to listeners attached to this object and
listeners attached to its ancestors.
|
|
Returns event types that have event listeners.
|
|
hasListener(type)
Indicates whether there are listeners for the specified event type.
|
|
<static> |
createjs.EventDispatcher.initialize(target)
Adds EventDispatcher methods into a target object.
|
off(type, listener, opt_useCapture)
|
|
on(type, listener, opt_scope, opt_once, opt_data, opt_useCapture)
|
|
removeAllListeners(opt_type)
Removes all listeners for the specified type, or all listeners of all types.
|
|
willTrigger(type)
Indicates whether there are listeners for the specified event type on this
object or its ancestors.
|
Class Detail
createjs.EventDispatcher()
A class that can receive events and dispatch events. This class can dispatch
CreateJS events only to their target CreateJS objects. (This class cannot
dispatch capture events.)
Field Detail
<static>
createjs.EventDispatcher.AT_TARGET
Representing this dispatcher is in the target phase.
<static>
createjs.EventDispatcher.BUBBLING_PHASE
Representing this dispatcher is in the bubbling phase.
<static>
createjs.EventDispatcher.CAPTURE_PHASE
Representing this dispatcher is in the capture phase.
<static>
createjs.EventDispatcher.CLICK
The event ID of the 'click' event.
<static>
createjs.EventDispatcher.MOUSE_DOWN
The event ID of the 'mousedown' event.
<static>
createjs.EventDispatcher.PRESS_MOVE
The event ID of the 'pressmove' event.
<static>
createjs.EventDispatcher.PRESS_UP
The event ID of the 'pressup' event.
Method Detail
{Function|Object}
addListener(type, listener, opt_useCapture)
Adds the specified event listener. Note that adding multiple listeners to the
same function will result in multiple callbacks getting fired.
Example
function handleClick(event) {
// Click happened.
}
displayObject.addEventListener("click", handleClick);
- Parameters:
- {string} type
- {Function|Object} listener
- {boolean=} opt_useCapture
- Returns:
- {Function|Object}
{boolean}
contains(child)
Returns whether the specified object is either this container or its
descendant.
- Parameters:
- {createjs.EventDispatcher} child
- Returns:
- {boolean}
{boolean}
dispatch(value, opt_target)
Dispatches the specified event to all listeners.
Example
// Use a string event
this.dispatchEvent("complete");
// Use an Event instance
var event = new createjs.Event("progress");
this.dispatchEvent(event);
- Parameters:
- {Object|string|Event} value
- {Object=} opt_target
- Returns:
- {boolean}
{boolean}
dispatchNotification(type)
Dispatches a notification event, which consists only of a type name.
- Parameters:
- {string} type
- Returns:
- {boolean}
{boolean}
dispatchRawEvent(event)
Dispatches a createjs.Event object to listeners attached to this object and
listeners attached to its ancestors. NOTE: this method does not implement the
capture phase, dispatching an event from the stage to this target. Games do
not use capture events so often that this method removes its implementation.
(For games consisting of thousands of CreateJS objects, it takes long time to
dispatch an event from the stage object to this target on Android browsers.)
- Parameters:
- {createjs.Event} event
- Returns:
- {boolean}
{number}
getEventTypes()
Returns event types that have event listeners.
- Returns:
- {number}
{boolean}
hasListener(type)
Indicates whether there are listeners for the specified event type.
- Parameters:
- {string} type
- Returns:
- {boolean}
<static>
createjs.EventDispatcher.initialize(target)
Adds EventDispatcher methods into a target object.
- Parameters:
- {Object} target
off(type, listener, opt_useCapture)
- Parameters:
- type
- listener
- opt_useCapture
on(type, listener, opt_scope, opt_once, opt_data, opt_useCapture)
- Parameters:
- type
- listener
- opt_scope
- opt_once
- opt_data
- opt_useCapture
removeAllListeners(opt_type)
Removes all listeners for the specified type, or all listeners of all types.
Example
// Remove all listeners
displayObject.removeAllEventListeners();
// Remove all click listeners
displayObject.removeAllEventListeners("click");
- Parameters:
- {string=} opt_type
{boolean}
willTrigger(type)
Indicates whether there are listeners for the specified event type on this
object or its ancestors. A return value of true indicates that if a bubbling
event of the specified type is dispatched from this object, it will trigger
at least one listener. This is similar to the
EventDispatcher.hasListener() method but it searches the entire event
flow for a listener, not just this object.
- Parameters:
- {string} type
- Returns:
- {boolean}