Custom class dependencies: None
Flash of course has built-in styles for line strokes, but none of them accomplished what I needed that CSS seems to do so intelligently. This is a simple dashed line drawn pixel for pixel with no antialiasing. This class attempts to make this process easy to use and control.
What It Does
First it draws a bitmap that will be used as a tile, then repeats that tile for a bitmap fill that will ultimately become the dashed line. The arguments for the class constructor are as follows, which are also available after instantiation through public instance properties:
- dash:Number – the size of the dash
- space:Number – the space in between the dashes
- w:Number – the width of the line
- h:Number – the height of the line
- color:String – the hexadecimal value of the dashes (no ‘0x’ needed, though ‘#’ may be included)
Example: A 1000 pixel long red verticle line
var line:DashedLine = new DashedLine();
line.width = 1000;
line.color = "FF0000";
line.rotation = 90;
addChild(line);
Something important to note is that the greatest of the width and height properties is used as the length of the line. The least of these properties is used as the thickness. That means that the line will automatically know if the dashes should be repeating vertically or horizontally. Also, the color property is a 6 digit string to not have to worry about the hexidecimal alpha value.
com.jimisaacs.display.DashedLine
Comment if you have any questions, or suggestions.
Leave a Reply