Rotation with movement bug

[color=black][font=Arial]I’m trying to make a RTS game in flashMX 2004. I was amazed that no-one else seems to have done one and I thought it would be easy! Like I so often am, I was wrong![/font][/color]

[color=black][font=Arial] [/font][/color]

[color=black][font=Arial]The best example I can think of to explain this is; imagine trying to program a car that chases the mouse. I want to rotate the car in the direction of the mouse, but cars can’t turn on the spot, cars turn gradually in an arc as they move forward.[/font][/color]

[color=black][font=Arial]Which all works perfectly fine, unless the mouse passes by the left of the car, because then the variable myDegrees jumps from 180 to -180 or visa-versa, causing the car to rotate the long way around, until it’s pointing towards the mouse again![/font][/color]

[color=black][font=Arial] [/font][/color]

[color=black][font=Arial]There must be an easy way to sort this bug, and I’m probably just being dumb, so could someone smarter than me please give me a hand![/font][/color]
[color=black][font=Arial]…anyway, heres the code. I know I havn’t got the object moving in an arc yet, for now thats unimportant, but hopefully this gives you the idea.[/font][/color]
[font=Times New Roman][size=3] [/size][/font]

[size=3][font=Times New Roman]onClipEvent (enterFrame) { [/font][/size]

[size=3][font=Times New Roman] // Find rotation[/font][/size]

[size=3][font=Times New Roman] myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);[/font][/size]

[size=3][font=Times New Roman] myDegrees = Math.round(myRadians*(180/Math.PI));[/font][/size]

[size=3][font=Times New Roman] // Find Movement[/font][/size]

[size=3][font=Times New Roman] _root.yChange = Math.round(_root._ymouse - this._y);[/font][/size]

[size=3][font=Times New Roman] _root.xChange = Math.round(_root._xmouse - this._x);[/font][/size]

[size=3][font=Times New Roman] _root.yMove = Math.round(_root.yChange/30);[/font][/size]

[size=3][font=Times New Roman] _root.xMove = Math.round(_root.xChange/30);[/font][/size]

[size=3][font=Times New Roman] // Apply movement[/font][/size]

[size=3][font=Times New Roman] this._y += _root.yMove;[/font][/size]

[size=3][font=Times New Roman] this._x += _root.xMove;[/font][/size]

[size=3][font=Times New Roman] // Apply rotation[/font][/size]

[size=3][font=Times New Roman] if (myDegrees > this._rotation) this._rotation += 20;[/font][/size]

[size=3][font=Times New Roman] if (myDegrees < this._rotation) this._rotation -= 20;[/font][/size]

[font=Times New Roman][size=3]}[/size][/font]

[font=Times New Roman][size=3] [/size][/font]

[font=Times New Roman][size=3]Thanks[/size][/font]