普通做法:

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));

  

posted on 2017-09-09 10:09  我是cdt  阅读(169)  评论(0编辑  收藏  举报