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

[ActionScript 3.0] AS3虚线绘制方法

时间:2015-10-12 22:42:57      阅读:361      评论:0      收藏:0      [点我收藏+]

标签:

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

 

[ActionScript 3.0] AS3虚线绘制方法

标签:

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

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