import flash.display.Sprite;
var container:Sprite = new Sprite();
container.x = 0;
container.y = 0;
addChild(container);
var test:Sprite;
var i:int = 0;
while (i < 10) {
test = new Sprite();
test.graphics.beginFill(0x000000);
test.graphics.drawRect(0 + i*10,0 + i*10,0 + i*10,0 + i*10);
test.name = "test" + i;
test.x = 200;
test.y = 100;
container.addChild(test);
i++;
}
for (var k:int = 0; k < container.numChildren; k++) {
trace(container.getChildAt(k).name);
}
Do begin fill before draw rect, and I think you need to set the x and y too.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Sprite.html