[ActionScript] AS3 绘制虚线

 import flash.geom.Point;
import flash.display.MovieClip;
import flash.display.Graphics; function drawDashed(mc:Sprite,p1:Point,p2:Point,length:Number=5,gap:Number=5):void
{
var max:Number = Point.distance(p1,p2);
var l:Number = 0;
var p3:Point;
var p4:Point;
while(l<max)
{
p3 = Point.interpolate(p2,p1,l/max);
l+=length;
if(l>max)l=max
p4 = Point.interpolate(p2,p1,l/max);
mc.graphics.lineStyle(1,0xff00ff,1)
mc.graphics.moveTo(p3.x,p3.y)
mc.graphics.lineTo(p4.x,p4.y)
l+=gap;
}
}
var mc:MovieClip=new MovieClip();
addChild(mc);
drawDashed(mc,new Point(100,100),new Point(500,100),5,5);
上一篇:正则表达式匹配html标签里面的内容


下一篇:转:CentOS---网络配置详解