How to set linestyle to solid/dashed/dotted/ragged/stippled in flash?

后端 未结 1 1953
借酒劲吻你
借酒劲吻你 2021-01-14 04:33

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.lineStyl

1条回答
  •  旧巷少年郎
    2021-01-14 04:49

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

    0 讨论(0)
提交回复
热议问题