Method: on

Add an event listener method for an event.
on (String || Array eventName, Function call, Object context, Boolean oneShot, Boolean sendEventName)
  • String || ArrayeventName The name of the event to listen for (string), or an array of events to listen for.
  • Functioncall The method to call when the event listener is triggered.
  • Objectcontext The context in which the call to the listening method will be made (sets the 'this' variable in the method to the object passed as this parameter).
  • BooleanoneShot If set, will instruct the listener to only listen to the event being fired once and will not fire again.
  • BooleansendEventName If set, will instruct the emitter to send the event name as the argument instead of any emitted arguments.
Returns Object The event listener object. Hold this value if you later want to turn off the event listener.

Add an Event Listener

// Register event lister and store in "evt"
var evt = myEntity.on('mouseDown', function () { console.log('down'); });

Listen for Event Data

// Set a listener to listen for the data (multiple values emitted
// from an event are passed as function arguments)
myEntity.on('hello', function (arg1, arg2) {
    console.log(arg1, arg2);

// Emit the event named "hello"
myEntity.emit('hello', ['data1', 'data2']);

// The console output is:
//  data1, data2
© Copyright 2013 Irrelon Software Limited. All Rights Reserved. UK Registered Company Number: 07522767
Isogenic (ī´sōjen´ik): Adj originating from a common source; possessing the same genetic composition.
Strange Things Happen at the One Two Point