I wrote an (untested) function for you to quickly generate rectangles with borders and stuff.
/**
* Create a rectangle or outlined rectangle.
* @param rect The rectangle to create.
* @param color The color of the rectangle or border.
* @param borderWidth The thickness of the border.
* @return The new rectangle.
*/
public function createRectangle(rect:Rectangle, color:uint = 0xffffffff, borderWidth:int = 0):BitmapData
{
var b:BitmapData = new BitmapData(rect.width, rect.height, true, color);
if (borderWidth > 0)
{
var r:Rectangle = rect.clone();
r.inflate(-borderWidth);
b.fillRect(r, 0);
}
return b;
}
Here’s how you’d use it.
// Create a 128x256 solid red rectangle Image.
var solid:Image = new Image(createRectangle(new Rectangle(0, 0, 128, 256), 0xff0000));
// Create a 32x48 hollow blue rectangle Stamp with a 2 pixel border.
var outline:Stamp = new Stamp(createRectangle(new Rectangle(0, 0, 32, 48), 0x0000ff, 2));