Return to Snippet

Revision: 31616
at September 9, 2010 19:55 by jaredyeo


Initial Code
addEventListener(MouseEvent.CLICK, fOnEvent, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, fOnEvent, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, fOnEvent, false, 0, true);

function fOnEvent(e : *) : void
{
	var vAngle : Number;
	
	switch (e.type)
	{
	case MouseEvent.MOUSE_DOWN:
		switch (e.target.name)
		{
		case "pbGrip":
			stage.addEventListener(MouseEvent.MOUSE_MOVE, fOnEvent, false, 0, true);
			break;
		}
		break;
	case MouseEvent.MOUSE_UP:
		stage.removeEventListener(MouseEvent.MOUSE_MOVE, fOnEvent);
		break;
	case MouseEvent.MOUSE_MOVE:
		vAngle = Math.atan2(mouseY - mcHandle.y, mouseX - mcHandle.x);
		mcHandle.rotation = vAngle * 180 / Math.PI;
		e.updateAfterEvent();
		break;
	}	
}

Initial URL

                                

Initial Description

                                

Initial Title
Drag rotate AS3

Initial Tags

                                

Initial Language
ActionScript 3