Rotation help

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:


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?