Return to Snippet

Revision: 28176
at July 2, 2010 23:07 by IsoJon


Initial Code
// "rota" is your movieclip/sprite

var dx : Number;
var dy : Number;

stage.addEventListener( Event.ENTER_FRAME, checkMouse );

function checkMouse( evt : Event ) : void
{
	dx = mouseX - rota.x;
	dy = mouseY - rota.y;
	rota.rotation = (Math.atan2(dy, dx) * 180 / Math.PI);
}

Initial URL

                                

Initial Description
This is a simple snippet to rotate an item with the mouse\'s position at a fixed point.

Initial Title
Rotate an Item based on Mouse Position

Initial Tags

                                

Initial Language
ActionScript 3