So once more I have a problem.
I'll illustrate it with this flash: Link.
Just move your mouse around and the arrow will follow. Here's the problem: when you cross the +/- 180, it goes all the way around rather than crossing over. I know why this happens (see code) but I can't think of a solution.
I know there's been a question on this exact same thing before but I cannot find it. Help/suggestions?
Here's the simple code:
// arr is the arrow on the stage
// output is the dynamic text box
addEventListener(Event.ENTER_FRAME, Loop, false, 0, true);
var rot:Number = arr.rotation;
function Loop(e:Event):void {
var dy:Number = mouseY - arr.y;
var dx:Number = mouseX - arr.x;
var finalAngle:Number = 180 / Math.PI * Math.atan2(dy, dx);
if (rot > finalAngle) rot -= 5;
if (rot < finalAngle) rot += 5;
arr.rotation = rot;
output.text = "Mouse Rotation: " + Math.round(finalAngle).toString() + "\nCurrent Rotation Variable: " + Math.round(rot).toString() + "\nRotation of Arrow: " + Math.round(arr.rotation).toString();
}