April 11, 2008 | Posted in: ActionScript 2,Code,Flash by Quentin

UPDATE TO THE UPDATE: Although I am no longer supporting the AS2 files, it would seem that quite a few people are still requesting them. Therefore I am once again making them available for the masses. Please be warned: I am no longer supporting or updating these classes. Download the files here. Enjoy.

UPDATE: The files for the AS2 version are no longer available. I’ve transitioned completely to AS3 and will no longer be coding or supporting AS2 classes that I’ve written.

Since we’re just getting started, I figured I’d post something both extremely simple yet, fairly useful to those curious about getting their feet wet with Flash’s drawing API or those already familiar but currently lacking a simple solution for drawing boxes. For me at least, these classes cut down on a ton of work, when I want to create an interface exclusively in AS.

Here’s the basic idea: You want to draw a box using the drawing API, with two or three rounded corners. Easy enough, yeah? Well, you also want to be able to resize those boxes without any distortion on those corners. Even easier you say? How about adding a gradient to that box? Oh, and then we need to add a smaller box on top of that box with a stroke and one rounded corner and position it 20 pixels from the right edge of the bigger box behind it. Sounds easy, right? Well, it is, but it’s also a hell of a lot of code to write, especially if your plan is to draw an entire interface with the drawing API (crazy, I know).

Basically, what I’ve done, is created a few classes (AS2) to simplify these tasks quite a bit. A sample .fla is also included for you to play around with and test for different results. You can download the files here. An AS3 version is forthcoming. For an AS3 version of my Box Class, see the next post.

I know, nothing groundbreaking here, but I hope these are as useful for you as they have been for me over the past few years. Feel free to modify them, make the code prettier, move things around, etc. As well, be sure to leave any questions or comments you may have concerning these classes below.

Stay tuned. There are more where these came from.