AS3 Dotted Line Class

Here is an ActionScript 3 class I use all the time to draw pixel perfect dotted lines in Flash. Free for any use other than reselling.

Add Comment

Discussion 14 Comments

  1. Brian says:

    First!

  2. Brian says:

    And thanks!

  3. Ben says:

    Awesome. By the way, what a great way to separate your functions in your code!

  4. Bruno says:

    Very good job ! Very orderly in your work. :)

  5. Diego SA says:

    Simple and useful!

  6. Excelent! Thanks man!

  7. dbam says:

    Definitely a time-saver, thank You for sharing!
    Allow me two notes though, what i saw after 2 minutes of testing…
    1. in the constructor the “dotAlpha” doesn’t have a type declaration, i used Number, like “dotAlpha:Number = 1″.
    2. the variable “tile” of type BitmapData has a height of “_h +1″, that gave me a one pixel artifact ( occasionally ), changing it to just “_h” gives the desired result…i’m wondering why the +1 though.

    Still, nothing that one wouldn’t notice after using Your class – easy to pin.
    Great share, thanks again Jay!

  8. jgh says:

    Good!一个字,“好”

  9. SDC says:

    just looking at the AS really quick and I’m still getting use to using classes and I figured out all the values except for the “0.9″. What does that control?

    var s:Shape = new DottedLine(630, 1, 0×603120, 0.9, 1, 2);

    • SDC says:

      Ok I figured that out. But now another question. In the AS file, _h is more of a stroke weight that an actual height. How would the AS be altered to have the properties control a line that runs vertically instead of horizontal?

  10. Roman says:

    “How would the AS be altered to have the properties control a line that runs vertically instead of horizontal?”

    I would like to know this too.

  11. maciej says:

    import com.warmforestflash.drawing.DottedLine;
    import flash.display.*;
    import flash.events.*;

    stage.align=StageAlign.TOP_LEFT;
    stage.scaleMode=StageScaleMode.NO_SCALE;
    stage.addEventListener(Event.RESIZE, resizeHandler);

    function resizeHandler(e:Event=null):void{

    var s:Shape=new DottedLine(stage.stageWidth – 44, 1, 0×603120, 1, 1, 2);
    addChild(s);

    s.x = 22;
    s.y = 22;

    }
    resizeHandler()

    On the right side of the site is not align. How to change the parameters to align dot 22px on the left site and 22px on the right side?

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.