标签:
import flash.geom.Point; import flash.display.MovieClip; import flash.display.Graphics; var mc:MovieClip=new MovieClip(); addChild(mc); drawDashed(mc,new Point(100,100),new Point(500,100),5,5); function drawDashed(mc:Sprite,p1:Point,p2:Point,length:Number=5,gap:Number=5):void { var max:Number = Point.distance(p1,p2); var len:Number = 0; var p3:Point; var p4:Point; while(len<max) { p3 = Point.interpolate(p2,p1,len/max); len+=length; if(len>max)len=max p4 = Point.interpolate(p2,p1,len/max); mc.graphics.lineStyle(1,0xff00ff,1) mc.graphics.moveTo(p3.x,p3.y) mc.graphics.lineTo(p4.x,p4.y) len+=gap; } }
标签:
原文地址:http://www.cnblogs.com/frost-yen/p/4872891.html