var shapes:Array = new Array();
for (var i:int = 0; i<300; i++){
var s:Shape = new Shape();
s.x = Math.random()* stage.stageWidth;
s.y = Math.random()* stage.stageHeight;
s.graphics.lineStyle(0,0x000000);
s.graphics.beginFill(0xCCCCCC);
s.graphics.drawCircle(0,0, Math.random()*s.y / 5);
shapes.push(s);
}
// comment this out to remove sorting
shapes.sortOn("width", Array.NUMERIC);
for (i = 0; i<shapes.length; i++){
addChild(shapes[i]);
}
This uses Array.sortOn() to do some basic z-sorting based on the width property of some circle shapes.