Here’s a class that I wrote. It’s just a bunch of static functions to help find common values like the angle of an object, the point to tween to after that angle has been found etc etc…
package { import flash.geom.Point; /** * @author Dan Sanderson * @email dan@pldm.co.uk * @url dev.pldm.co.uk */ public class PointFinder { public static function findPoint(angle : Number, distance : Number) : Point { var radian : Number = angle * (Math.PI/180); var point : Point = new Point(); point.x = distance * Math.cos(radian); point.y = distance * Math.sin(radian); return point; } public static function findAngle(startPosition : Point, targetPosition : Point) : Number { var newAngle : Number; if(targetPosition) { var newX : Number = startPosition.x - targetPosition.x; var newY : Number = startPosition.y - targetPosition.y; newAngle = -Math.atan2(newX, newY)/(Math.PI/180); } else { newAngle = 0; } return newAngle; } public static function findDistance(startPosition : Point, targetPosition : Point) : Number { var distance : Number = Math.round(Math.sqrt(((startPosition.x - targetPosition.x) * (startPosition.x - targetPosition.x)) + (startPosition.y - targetPosition.y) * (startPosition.y - targetPosition.y))); return distance; } // This function is for converting wierd rotation values (like -58) to degrees. public static function convertRotationValueToDegress(rotation : Number) : Number { var degrees : Number; if(rotation < 0) { degrees = 180 + (180 - Math.abs(rotation)); } else { degrees = rotation; } return degrees; } } }