Diagonal line filled box with ActionScript3
Just a very quick post about a potentially useful code snippet that I recently wrote in ActionScript. I discovered, after attempting to Google my way through a small bit of development, that I couldn’t find the exact solution I was looking for.
I was attempting to find some code for making a rectangle using the AS3 graphics API which is filled with a background colour and some diagonal lines (illustrated above by the green and blue boxes). Fairly straightforward one would assume however most of the examples I found involved drawing the lines and using a mask to create the rectangular shape. Considering the overhead of using masks in Flash and the fact that within my application this box will be being rendered extremely regularly to simulate movement I decided to write a little utility using only the graphics API and some GCSE maths.
The code won’t format properly in the blog so I’ve uploaded the entire DrawingUtil.as class for download here.


