数学公式 AS3应用

时间:2021-09-08 10:00:30

普通做法:

var pA:Point=new Point(100,100);
var pB:Point=new Point(300,200);
var dx:Number=pA.x-pB.x;
var dy:Number=pA.y-pB.y;
var dist:Number=Math.sqrt(dx*dx+dy*dy);
//勾股定理
trace(dist);

 

as3自带API

var p1:Point=new Point(50,50);
var p2:Point=new Point(275,200); trace(Point.distance(p1,p2));