I have a clip which orients itself to the mouse using Math.atan2(). The rotation calculation of the clip includes some deceleration to smooth the effect. The calculation goes crazy when:
while (d < _rotation-180) d += 360;
while (d > _rotation+180) d -= 360;
Your problem was caused by the fact that atan2 returns a value from -PI to PI (which you were converting to -90 to 270).
The point where the mouse went crazy was the point where it switched from positive to negative.
I changed it to find the nearest equivalent rotation point on the circle (for any given angle, the angle you want to tween to shouldn't be there 180 degrees away). Adding or subtracting 360 doesn't change the desired angle, but reduces the amount of tweening that _rotation needs to find it.
Thanks, jbum - perfect! And thanks for the explanation, I know it's only elemental trig but I haven't touched it since high school and I have to learn it all over again.