如何在flash中将linestyle设置为solid / dashed / dotted / ragged / stippled?

时间:2010-01-19 00:49:37

标签: flash

我正在使用Flash CS4,它具有绘制实线/虚线/点线/参差不齐/点画线条的功能。但是,我找不到用于绘制这些样式的API的API。 Graphics.lineStyle()不支持它。如何以编程方式绘制样式线?

编辑:包括衣衫褴褛/点画式

1 个答案:

答案 0 :(得分:3)

手动解决方案,找到here。在AS2下运行良好,但可能需要一些调整才能使其在AS3下运行。

var dotWidth:Number = 4;
var spaceBetweenDots:Number = 1;
var totalLineWidth:Number = 250;
var dotsPerLine:Number = totalLineWidth / (dotWidth + spaceBetweenDots);
for (var i:Number = 0; i < dotsPerLine; i++)
{
    var dottedLine:MovieClip = _root.createEmptyMovieClip("topLine_" + i, this.getNextHighestDepth());
    dottedLine.lineStyle(0, 0x000000, 100);
    dottedLine.lineTo(dotWidth, 0);
    dottedLine._x = i * (dotWidth + spaceBetweenDots);
    dottedLine._y = 50;
}

你可以在那里随机添加一点来获得粗糙的线条:

var dotWidth:Number = 4;
var spaceBetweenDots:Number = 0;
var totalLineWidth:Number = 250;
var dotsPerLine:Number = totalLineWidth / (dotWidth + spaceBetweenDots);
var ragVariance: Number = 2;
for (var i:Number = 0; i < dotsPerLine; i++)
{   
    var raggedLine:MovieClip = _root.createEmptyMovieClip("topLine_" + i, this.getNextHighestDepth());
    raggedLine.lineStyle(0, 0x000000, 100);
    raggedLine.lineTo(dotWidth-random(ragVariance), random(ragVariance));
    raggedLine._x = i * (dotWidth + random(spaceBetweenDots));
    raggedLine._y = 100+random(ragVariance);
}