form = function


about f = f



drawing methods


about formequalsfunction draw methods

One of my greatest frustrations after first exploring the new draw methods in Macromedia Flash MX was the trouble I had using curveTo effectively. It was non-intuitive and non-trivial (at least to me) to draw a 'normal' circle or arc. So in my frustration, I created an extension to the Macromedia Flash built-in drawing API to handle the creation of those shapes. Over time, this extension multiplied. They eventually took on a life of their own, becoming a larger toolset for drawing shapes and structures.  

In the end I had nine new tools.
Some are useful, others whimsical, but all of them are free to use as you see fit. They are free of charge or obligation. I have endeavored to make these methods robust and useful, however I can make no guarantees about their suitability to your specific needs. I similarly make no guarantees that they are bug or problem free: caveat emptor. I have commented them heavily and hopefully this will let those encountering the built-in drawing methods for the first time understand how they can be used to create useful tools. It should also provide sufficient information for those more experienced to adapt them to their specific needs or styles.
One last thing before we get to the methods themselves: There are ways to optimize ActionScript to increase the speed of the code execution, but at the cost of making the ActionScript more obtuse. These methods serve a dual purpose. The first is to reduce drawing complex elements to a single line of code. The second is to be a tool for learning. Because of the second (and to my mind, more important) purpose, I have left some of these methods 'unoptimized'. For those that are not yet familiar with the Flash MX built-in drawing methods, be sure to check out theIntroduction to Macromedia Flash MX Drawing Methodsat Macromedia's Designer & Developer Center.
Okay, now we've cleared that up, on to the methods...

The individual AS include files are available by clicking the orange titles. If you want the sample FLA files, you can download them in either SIT or ZIP format packages that include all the files below.

all AS files with example FLA files

draw_methods.zip (428k)
draw_methods.sit (324k)

These packages contain all the below AS files along with FLA files for the examples shown.

individual AS files

mc.dashTo is a metod for drawing dashed (and dotted) lines. I made this to extend the lineTo function because the built-in method doesn’t have the cutom line types that the line tool has in Flash.

mc.drawArc is a method for drawing regular and eliptical arc segments. This method replaces one I originally released to the Flash MX beta group titled arcTo and contains several optimizations based on input from the following people: Robert Penner, Eric Mueller and Michael Hurwicz.
mc.drawBurst is a method for drawing bursts (rounded star shaped ovals often seen in advertising). This seemingly whimsical method actually had a serious purpose. It was done to accommodate a client that wanted to have custom bursts for 'NEW!' and 'IMPROVED!' type elements on their site... personally I think those look tacky, but it's hard to argue with a paying client. :) This method also makes some fun flower shapes if you play with the input numbers.
mc.drawGear is a method that draws gears... you know, cogs with teeth and a hole in the middle where the axle goes? Okay, okay... so nobody *needs* a method to draw a gear. But it was an easy adaptation of the polygon method so I did it anyway. Enjoy.
mc.drawOval is a method for creating circles and ovals. Hopefully this one is pretty straight forward. This method, like most of the others, is not as optimized as it could be. This was a conscious decision to keep the code as accessible as possible for those either new to AS or to the math involved in plotting points on a curve.
mc.drawPoly is a method for creating regular polygons. I can draw the polys either clockwise or counter-clockwise (based on sides argument) so that you can use it to knock holes in dynamically created masks.
mc.drawRect is a method for drawing rectangles and rounded rectangles. Regular rectangles are sufficiently easy that I often just rebuilt the method in any file I needed it in, but the rounded rectangle was something I was needing more often, hence the method. The rounding is very much like that of the rectangle tool in Flash where if the rectangle is smaller in either dimension than the rounding would permit, the rounding scales down to fit.
mc.drawStar is a method for drawing star shaped polygons. Like drawPoly, it can draw stars in either direction for creating knockouts.
mc.drawWedge is a method for drawing pie shaped wedges. Very useful for creating charts. Again, special thanks is due to: Robert Penner, Eric Mueller and Michael Hurwicz for their contributions.


© 2002 ric ewing