Mouse Follower with Angle Rotation

First create an arrow Movie Clip ( make sure the tip of the arrow is on the register point of the Movie Clip ) and add it to the scene and name it “arrow”.

You will also need Caurina Tweener ( but other tweeners can be used also ).

import caurina.transitions.Tweener;

stage.addEventListener(MouseEvent.MOUSE_MOVE, Moving, false, 0, true);

function Moving(e:Event):void
var X:Number =  mouseX - arrow.x;
var Y:Number = (mouseY - arrow.y) * -1;

var angle:Number = Math.atan(Y/X)/(Math.PI/180);

Tweener.addTween(arrow ,{x :mouseX, y: mouseY, time:2});

if (X<0) { 		angle += 180; 	} 	

if (Y>=0 && Y<0) {  angle += 360;}

arrow.rotation = (angle*-1) + 90;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s