# Mouse follow rotation with ease

**URL:** <https://forum.kirupa.com/t/mouse-follow-rotation-with-ease/229208>\
**Category:** Uncategorized\
**Created:** [June 14, 2007, 9:24pm UTC](https://forum.kirupa.com/t/mouse-follow-rotation-with-ease/229208 "2007-06-14T21:24:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [June 14, 2007, 9:24pm UTC](https://forum.kirupa.com/t/mouse-follow-rotation-with-ease/229208/1 "2007-06-14T21:24:21Z")

</div>

I’m using the basic mouse follow technique i stole from some tutorial, yes i understand it, but im in a rush:D

I’m trying to make it ease to the spot but it doens’t seem like there is a way.

It is jumpy, i would like to it to slowly smooth to the current mouse location. It’s going to be used for a touch screen;)

Heres my current AS:

```auto
stop()
face.onRollOver = function(){

startDrag("mouseTarget", true);
onMouseMove = function(){

mouse_x = mouseTarget._x;
mouse_y = mouseTarget._y;

xDistance = mouseTarget._x - face._x;
yDistance = mouseTarget._y - face._y;

// set the normalisation factor
if (Number(xDistance)<0) {
    normalise = -1 * xDistance;
} else {
    normalise = xDistance;
}
if (Number(yDistance)<0) {
    normalise = Number(normalise)+Number((-1 * yDistance));
} else {
    normalise = Number(normalise)+Number(yDistance);
}
// determine the direction
if ((Number(xDistance)>=0) and (Number(yDistance)>=0)) {
    direction = 90*(yDistance/normalise);
} else if ((Number(xDistance)<=0) and (Number(yDistance)>=0)) {
    direction = Number(-1*90*(xDistance/normalise))+90;
} else if ((Number(xDistance)<=0) and (Number(yDistance)<=0)) {
    direction = Number(-1*90*(yDistance/normalise))+180;
} else {
    direction = Number(90*(xDistance/normalise))+270;
}

// set direction of needle and bullet
needle._rotation = direction;

}
}
face.onRollOut = function(){
    mouseTarget.stopDrag();
}

```

Heres a link to the current SWF:  
[http://www.joshuajonah.com/compass.swf](http://www.joshuajonah.com/compass.swf)

Heres a link to the current SFLA:  
[http://www.joshuajonah.com/compass.fla](http://www.joshuajonah.com/compass.fla)
