ActionScript Drawing Method – SquiglyLineTo

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, 0×000000, 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!

One thought on “ActionScript Drawing Method – SquiglyLineTo

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

5,281 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">