Class MessageDispatcher

The MessageDispatcher class is the base class for all classes that posts messages.

Global messages will not be dispatched on non GameObject objects.

Methods

MessageDispatcher(checkForStage) constructor

Creates new MessageDispatcher instance

Parameters
checkForStage : boolean
on(name, callback, context) method

Adds listener by given name and callback.

Parameters
name : string — Message name.
callback : function — Function to be called on message send.
context : * — Object to be used as this in callback function.
Returns
MessageBinding
off(names) method

Removes all bindings by given message name.

Parameters
names : string — One or more message name.
Returns
void
once(name, callback, context) method

Adds listener by given name and callback. Binding will be automatically removed after first execution.

Parameters
name : string — Message name.
callback : function — Function to be called on message send.
context : * — Object to be used as this in callback function.
Returns
MessageBinding
post(name, params) method

Posts message with a given params.

Adding ~ character to the begging of the name will bubble message to the top of the tree.

Parameters
name : string — The name of a message
params : * — A list of params to send
Returns
void

Properties

parent : MessageDispatcher | null property
Returns parent MessageDispatcher.
stage : Stage | null property
Returns the stage Game Object to which this belongs to or null if not added onto stage.
path : string | null property
Returns string representing a url like path to this object in the display
tree.