# Rotation help

**URL:** https://forum.kirupa.com/t/rotation-help/267436
**Category:** Uncategorized
**Created:** [August 1, 2008, 12:45am UTC](https://forum.kirupa.com/t/rotation-help/267436 "2008-08-01T00:45:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![benweitzman](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@benweitzman](https://forum.kirupa.com/u/benweitzman)
#### Post date: [August 1, 2008, 12:45am UTC](https://forum.kirupa.com/t/rotation-help/267436/1 "2008-08-01T00:45:37Z")

</div>

I was just wondering if anybody knows how to handle this:  
I want to have a movieclip rotate to the mouse, but in such a way that it eases to it instead of just always being 100% rotated. The code I have is something a long the lines of:

```auto

var targetRot:Number = Math.atan2(mouseY-e.target.y,mouseX-e.target.x)*180/Math.PI
e.target.rv += (targetRot-e.target.rotation)/10
e.target.rv *= .5
e.target.rotation += e.target.rv

```

Now, the code works exactly as it’s supposed to, but when the difference between targetRot and e.target.rotation goes from 180 to -180 or something like that, it flips out. What should I do?
