ActionScript 3 Working with Geometry Getting the distance between two points


Example

Using vanilla mathematics:

var from:Point = new Point(300, 10);
var to:Point = new Point(75, 40);

var a:Number = to.x - from.x;
var b:Number = to.y - from.y;

var distance:Number = Math.sqrt(a * a + b * b);

Using inbuilt functionality of Point:

var distance:Number = to.subtract(from).length; // or
var distance:Number = Point.distance(to, from);