The following is a drawing class that I’ve used for the past year or so. I’m kind of using this article to test out various ways of doing syntax coloring in this blog. I use MoveableType, and I’m currently looking for some plug-in that will allow me to automatically publish code in the blog and have it look correct. Unfortunately, the only one I’ve found so far MTColorer, I wasn’t able to get working. There are a few that my friend Mason and I have looked at for WordPress that work pretty well and (like many WordPress things) are easily configurable/hackable and free. The code that I’ve included below (as well as the other code so far in this blog) is colored using the Actionscript HIghlighter featured on Arul’s Blog, which allows you to paste in your code and hit a button to get the styled text. Arul’s code does a great job, but you have to visit his site to style your code, and then also provide a download link to the text file of your code if you want to provide just a plain text version. But hey, it works. He notes on the site that there is the possibility of releasing the code once he cleans it up, so maybe there will be something one can post on their own site sometime soon.
As for the code below, it is a simple drawing class that allows you to easily draw a generic box, a hairline box, and a filled rectangle. The main reason, however, that I created the class, is for those occasions where you may need a box that is not filled and is not made up of flash lines. If you’ve used Flash enough, you know that if you draw a 3 pixel line box, the corners are often rounded looking, which doesn’t fly unless that is what you want in your design. I have worked on several projects that were to use photos that needed a “frame” of a certain width. The drawing class drawFrame method basically draws 4 filled boxes to create a rectangular “frame” of a certain thickness, made entirely of “fill” rather than lines, so the corners are nice and sharp. Of the instances where I have used this class, I have used the drawFrame method 90% of the time. Enjoy.