本文介绍了如何在Flash中将线条设置为实线/虚线/虚线/衣衫褴褛/点点线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是Flash CS4,它具有绘制实线/虚线/虚线/花边/点刻线的功能。但是,我找不到API来绘制这些样式的一行。 。
var dotWidth:Number = 4;可以在AS2下正常工作,但可能需要一些调整才能在AS3下工作。
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;
$ b $ p
$ b 你可以随意添加一些粗糙的线条:
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);
}
I am using Flash CS4, and it has a feature of drawing solid/dashed/dotted/ragged/stippled lines. But, I can't find API for drawing a line of these styles. Graphics.lineStyle() doesn't support it. How can I draw styled lines progammatically?
EDIT: Included ragged/stipple style
解决方案 Manual solution, found here. Works well under AS2, but might require some tweakign to make it work under 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;
}
You could add a bit random in there to get ragged lines:
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);
}
这篇关于如何在Flash中将线条设置为实线/虚线/虚线/衣衫褴褛/点点线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!