ActionScript 3 Working with Geometry Moving a point along an angle


Example

Assuming you have the angle you'd like to move in and an object with x and y values you want to move:

var position:Point = new Point(10, 10);
var angle:Number = 1.25;

You can move along the x axis with Math.cos:

position.x += Math.cos(angle);

And the y axis with Math.sin:

position.y += Math.sin(angle);

You can of course multiply the result of Math.cos and Math.sin by the distance you want to travel:

var distance:int = 20;

position.x += Math.cos(angle) * distance;
position.y += Math.sin(angle) * distance;

Note: The input angle must be in radians.