The system.events
package provides a W3C Event Model implementation.
Examples
var click = function( event ) { trace( "click: " + event ) ; }; var dispatcher = new EventDispatcher() ; dispatcher.addEventListener( Event.CLICK , click ) ; dispatcher.dispatchEvent( new Event( Event.CLICK ) ) ;
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 ) ) ;