How do I get a movie clip to follow the cursor?
Hi guys,
What I want:
Is a simple action where I have my company logo in the middle of the screen and it follows the cursor (not over the whole screen but within invisible borders).
What I use:
I have Flash Pro CS5, code is Actionscript 3.0 and my company logo has been converted to a movie clip.
What didn't work:
So I watched 2 different tutorials on how to do this and both didn't work.
With the first one I used this code:
function gradientOver(event:MouseEvent):void{
logomc.visible=true;
function reportStageMouse(event:MouseEvent):void{
var myStageX:Number=Math.round(event.stageX);
var myStageY:Number=Math.round(event.stageY);
var xTween:Tween=new Tween(logomc,"x", Strong.easeOut, logomc.x, myStageX, 1, true);
var yTween:Tween=new Tween(logomc,"y", Strong.easeOut, logomc.y, myStageY, 1, true);
}
stage.addEventListener(MouseEvent.MOUSE_MOVE,reportStageMouse);
}
function gradientOut(event:MouseEvent):void{
logomc.visible=false;
}
function gradientClick(event:MouseEvent):void{
logomc.visible=false;
}
gradient.addEventListener(MouseEvent.ROLL_OVER,gradientOver);
gradient.addEventListener(MouseEvent.ROLL_OUT,gradientOut);
gradient.addEventListener(MouseEvent.CLICK,gradientClick);
And with the second one I had to make a border by drawing an oval shape, turn it into a movie clip and put my logo inside of it. Then I used this code:
stage.addEventListener("mouseMove", arjun);
function arjun(e:MouseEvent):void
{
var var1 = mouseY - followins.y;
var var2 = mouseX - followins.x;
var radiusR = Math.atan2(var1,var2);
var degreeR = radiusR / (Math.PI / 180);
followins.rotation = degreeR;
}