# Object Follow cursor rotation problem, Actionscript 2 coding Flash

**URL:** <https://forum.kirupa.com/t/object-follow-cursor-rotation-problem-actionscript-2-coding-flash/276017>\
**Category:** flash\
**Created:** [November 21, 2008, 11:10am UTC](https://forum.kirupa.com/t/object-follow-cursor-rotation-problem-actionscript-2-coding-flash/276017 "2008-11-21T11:10:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![squarepig](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@squarepig](https://forum.kirupa.com/u/squarepig)\
**Post date:** [November 21, 2008, 11:10am UTC](https://forum.kirupa.com/t/object-follow-cursor-rotation-problem-actionscript-2-coding-flash/276017/1 "2008-11-21T11:10:18Z")

</div>

Hi

Can anyone help me sort out a flip problem with an mc clip that follows the mouse and rotates towards the movement but flips awkwardly when you move the mouse again.  
here is the code I found

//Place this on the mc

onClipEvent (load) {  
//\_x = 0;  
//\_y = 0;  
speed = 6;  
area = 0;  
}  
onClipEvent (enterFrame) {

//attach mc to the pointer if mouse over the area  
if (area == 0) {  
this.play();  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
\_x += (endX-\_x)/speed;  
\_y += (endY-\_y)/speed;

//rotate MC to follow the mouse angle  
this.onMouseMove = function() {  
\_rotation = (Math.atan2(\_root.\_ymouse-\_y, \_root.\_xmouse-\_x))\*(180/Math.PI);  
ease = 3;  
};  
}  
}

I’m a bit of a novice so please be gentle. Thanks in advance
