Thursday 18 September 2008

A custom class to draw dashed lines in Flash

Ever wanted to draw a beautiful dashed line in Flash with a single line of code?... Well you can't do it yet, but my code needs only three or four to intialize the object and then one for each line.

I made a custom class called DashedLine, which is an extension of the flash.display.Shape class. With it you can create a DashedLine instance that has the following methods:
drawDashedLine - Draws a dashed line between to points. You have to provide four coordinates.
drawDashedLineP - Draws a dashed line. You have to provide two Point objects.
drawDashedRectangle - Draws a dashed rectangle. You have to provide the two coordinates of the left top corner, and then width and height.
clearAll - Deletes all the lines

I wrote every explanation at the top of the class file DashedLine.as. Don't forget to import the file, I put it in a package called ccontinisio (so you'll remember me when you use it).
Don't bother to quote me when you use it, I'm not after personal glory :D

Here's the file:
DASHEDLINE_CLASS (.zip)

(manually copy this link if the above doesn't work...
http://ccontinisio.altervista.org/varie/DashedLine_class.zip)

3 comments:

  1. Just what I was looking for! Thanks!
    I guess why Adobe didn't include something like this in Flash in the first place...

    ReplyDelete
  2. Thanks for the above information you have provided....and the links are really cool i love it...great job thanks

    ReplyDelete