Namespace: events

system. events

The system.events package provides a W3C Event Model implementation.

Author:
License:

Examples

Basic usage with a callback function

var click = function( event )
{
    trace( "click: " + event ) ;
};

var dispatcher = new EventDispatcher() ;

dispatcher.addEventListener( Event.CLICK , click ) ;

dispatcher.dispatchEvent( new Event( Event.CLICK ) ) ;

Use the W3C DOM EventListener interface

var Click = function( name )
{
    this.name = name ;
}

Click.prototype = Object.create( EventListener.prototype ,
{
    constructor : { value : Click } ,
    handleEvent : { value : function( event )
    {
        trace( this + ' ' + this.name + ' event:' + event ) ;
    }}
});

var click1 = new Click( '#1') ;
var click2 = new Click( '#2') ;

var dispatcher = new EventDispatcher() ;

dispatcher.addEventListener( Event.CLICK , click1 ) ;
dispatcher.addEventListener( Event.CLICK , click2 ) ;

dispatcher.dispatchEvent( new Event( Event.CLICK ) ) ;

dispatcher.removeEventListener( Event.CLICK , click2 ) ;
dispatcher.dispatchEvent( new Event( Event.CLICK ) ) ;

Classes

Event
EventDispatcher

Namespaces

EventPhase