/ Published in: ActionScript 3

This is a simple snippet to rotate an item with the mouse\'s position at a fixed point.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// "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); }
Comments
