All pastes #795210 Raw Edit

Mine

public javascript v1 · immutable
#795210 ·published 2007-11-23 22:22 UTC
rendered paste body
import Xinf;import hxbase.events.Event;class Demo {		var r:Rectangle;	var handlers  : {		mouseUp   : Binding;		mouseDown : Binding;		mouseMove : Binding;	}		public function new() :Void {			r = new Rectangle();		r.style.fill = Color.RED;		r.x=r.y=100;		r.width=r.height=100;			var h = this.handlers;		h.mouseUp = Event.global(MouseEvent).up.bind(this, function(e) {			h.mouseUp.disable();			h.mouseMove.disable();		});		h.mouseUp.disable();		h.mouseMove = r.events.mouse.move.bind(this, onMouseMove);		h.mouseMove.disable();		h.mouseDown = r.events.mouse.down.bind(this, onMouseDown);				Root.attach( r );	}		public function onMouseDown( e:MouseState ) :Void {		handlers.mouseUp.enable();		handlers.mouseMove.enable();	}		public function onMouseMove( e:MouseState )	{		var o = { x:ofs.x-e.x, y:ofs.y-e.y };		ofs = e;		this.r.x -= o.x;		this.r.y -= o.y;	}		public static function main() :Void {		var d = new Demo();		Root.main();	}}