码迷,mamicode.com
首页 > 其他好文 > 详细

[ActionScript] AS3 绘制虚线

时间:2015-09-04 14:20:35      阅读:500      评论:0      收藏:0      [点我收藏+]

标签:

 1 import flash.geom.Point;
 2 import flash.display.MovieClip;
 3 import flash.display.Graphics;
 4 
 5 function drawDashed(mc:Sprite,p1:Point,p2:Point,length:Number=5,gap:Number=5):void   
 6 {    
 7     var max:Number = Point.distance(p1,p2);    
 8     var l:Number = 0;    
 9     var p3:Point;    
10     var p4:Point;    
11     while(l<max)    
12     {    
13         p3 = Point.interpolate(p2,p1,l/max);    
14         l+=length;    
15         if(l>max)l=max    
16         p4 = Point.interpolate(p2,p1,l/max); 
17         mc.graphics.lineStyle(1,0xff00ff,1)
18            mc.graphics.moveTo(p3.x,p3.y)    
19         mc.graphics.lineTo(p4.x,p4.y)    
20         l+=gap;    
21     }    
22 }   
23 var mc:MovieClip=new MovieClip();
24 addChild(mc);
25 drawDashed(mc,new Point(100,100),new Point(500,100),5,5);

 

[ActionScript] AS3 绘制虚线

标签:

原文地址:http://www.cnblogs.com/frost-yen/p/4781615.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!