2010-01-19 50 views

回答

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); 
} 
+0

謝謝,一定能得出點和虛線。但是衣衫襤褸/點刻花呢? – grayger 2010-01-19 01:51:44

+0

...給了一個嘗試。您可以使用ragVariance變量指定金額。 – sthg 2010-01-19 02:28:40

+0

再次感謝您。我預計這項工作的API,但你的方法也很好。 – grayger 2010-01-19 07:09:13