Angles, sines, cosines, moving an mc

Hi, I’m having some problems. I’m trying to create a function that moves a certain movieclip to a given x and y and at a given speed. It works only so that the movieclip now can move only to the right and I still haven’t figured out how to stop it. I’m suspecting that it has something to do with the angles and such. Here’s the function.

MovieClip.prototype.travelTo = function(xpos, ypos, speed) {
	this.moving = TRUE;
	this.ang = Math.atan((ypos - this._y)/(xpos-this._x));
	this.onEnterFrame = function() {
		this._x += Math.cos(this.ang) * speed;
		this._y += Math.sin(this.ang) * speed;
	}
}

See, I get the angle by using the arctan function on the difference between the given y and the current y of the movieclip and the given x and the current x of the movieclip. That’s line 3. Then I just make it move in the x direction by cos * speed each frame and in the y direction by sin * speed each frame. Seems simple enough, no? It should work but as I said, it can only move to the right. If I tell it to move somewhere to its left, it moves in the direct opposite direction - thus moving to the right.
I’ve included a .fla file (move.fla) with the demonstration, the function is in the frame and the movieclip goes to your mouse cursor when you press space (the red button is triggered by space and it calls the function).
I’ve also included an angles.fla, which I’ve made to demonstrate how I can’t get flash to display angles, sines and cosines correctly. For instance in the second quadrant, it displays a negative sine. And we all know the sine is always positive in the second quadrant.
And isn’t the angle supposed to go from 0 to 2PI? Here, it goes from 0 to PI/2 and then switches over to -PI/2. Strange indeed.
I’d appreciate it if someone could take a look at these flas.
Thanks in advance! :smiley: