ActionScript Drawing Method – SquiglyLineTo

1 actionscript,flash,website,work  |   August 15, 2006  |     567

In a project I am currently working on I am required to draw squigly lines using the drawing API, as they are a basic part of most skins of the common controls (dialog box, buttons..). I used Ric Ewing’s dashTo method as a basis to build a function called SquiglyLineTo:

MovieClip.prototype.squiglyLineTo = function(startx, starty, endx, endy, len, width)

  • the startx, starty, endx and endy parameters are self explanatory.
  • the len is the length of the squiggles
  • the width is the maximum length in pixels by which the squiggles goes out of the main line

The function draws curves on each side of the line alternatively, all are the same length but they do vary in “width”.

Sample usage to create a box:

lineStyle(1, 0x000000, 100);
squiglyLineTo(241,164, 400,164,2.5,1.5);
squiglyLineTo(400, 164, 400, 184, 2.5, 1.5);
squiglyLineTo(400, 184, 241, 184, 2.5, 1.5);
squiglyLineTo(241, 184, 241, 164, 2.5, 1.5);

Source code is found here.

Good day!

  • July 8, 2008 at 4:23 pm


    can you repost the AS file? I got a 404 on it…thanks

Leave a Reply