JavaScript events for custom objects
var Car = function () {
EventDispatcher.call( this );
this.start = function () {
this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
};
};
var car = new Car();
car.addEventListener( 'start', function ( event ) {
alert( event.message );
} );
car.start();
Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object.
Adds a listener to an event type.
The type of the listener that gets removed.
The listener function that gets removed.
Fire an event type.
Adds a listener to an event type.
The type of the listener that gets removed.
The listener function that gets removed.
Removes a listener from an event type.
The type of the listener that gets removed.
The listener function that gets removed.