[xinf] DOM Events?

Nicolas Cannasse ncannasse at motion-twin.com
Thu Jun 22 20:10:22 CEST 2006


>  * uses Strings as event type identifiers, defined as static variables in the corresponding classes (like MouseEvent.MOUSE_DOWN, but Event.ENTER_FRAME).

bad bad bad :)

>  * DOM events use an EventListener object like this:
> 	interface EventListener {
> 	    function handleEvent( evt:Event ) :Void;
> 	}
>    while AS3 uses functions as first-class objects, like:
> 	function(evt:Event):void

I prefer the AS3 way, but the problem is that with current haXe version, 
two delegates created doesn't have the same address.


> this way, you could do:
> 	public function onMouseDown( e:MouseEvent ) :Void {
> 		...
> 	}
> 	...
> 	addEventListener( MouseEvent.MOUSE_DOWN, new CastingEventListener<MouseEvent>( onMouseDown ) );

By using a signature of EventListener and no type constraint for the 
CastingEventListener, you can use type inference so you don't have to 
specify the type parameter.

Here's my take on the subject. I add an EventSite class that permit to 
remove the need for a type String, and still is very natural to handle.

Nicolas


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: haXeEvents.hx
Url: http://xinf.org/pipermail/xinf/attachments/20060622/39c6bca5/attachment.pot 


More information about the xinf mailing list