[FMX] Trouble with rotation and elasticity

Hey folks. I’m new to the forum and in need of some advice. I have a clip that rotates to orient itself towards the mouse when the mouse is over a given area. When the mouse leaves the area, the clip snaps back to its original position.

There are a few problems that I need help with:

  1. the clip snaps directly towards the mouse at the moment the mouse enters the clip; I would like it to actually rotate;
  2. the clip snaps directly back to its original position when the mouse leaves the clip; I would like it to ease back into position.

The code I am working with is below. I am currently using an easing function supplied by Robert Penner, but would be happy to try something else. Perhaps the real problem I am having is attaching functions to objects…

gearMC.anchor = 90
gearMC.startRotation = gearMC._rotation;

hitAreaMC.onEnterFrame = function() {
if (hitAreaMC.hitTest(_root._xmouse, _root._ymouse)) {
gearMC._rotation = Math.atan2(_ymouse-gearMC._y, _xmouse-gearMC._x)*180/Math.PI;
}
else {
gearMC._rotation = gearMC.anchor;
}
}

//Easing code courtesy of Robert Penner

Math.easeOutElastic = function (t, b, c, d, a, p) {
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs©) { a=c; var s=p/4; }
else var s = p/(2Math.PI) * Math.asin (c/a);
return a
Math.pow(2,-10t) * Math.sin( (td-s)(2Math.PI)/p ) + c + b;
};