Now that we know how DisplayObjectContainers can add children and how the display list manages them, our next question my be "How do with deal with multiple children?"Well, it's pretty simple. When I said that "depth" no longer exsists in actionscript, I only mean the literal word and in terms of layering or "z-index". The concept on the other hand (z-index), is still in use and is now much easier to work with. If we think of a DisplayObjectContainer as an array, we could assume it's children would look something like this:

var parent:Array = new Array(child, child, child, child);

Infact, this is very similar to how a parent object deals with its children. the child in the last index will be visually above the rest and so on through all of it's children. When we use the addChild() method to add a child, the child is automaticly added to the end of the child list(similar to an Array.push() method). Now of course, if all we could do is add children and have them only be placed last in the child list, this would not be very handy. Of course though, not only can we move or add a child to any index of a child list, we can also easily swap them. The addChildAt() method allows you to add a new child and also set it's index amoung the existing children of a parent. lets see how this works:

// main timeline: frame 1
var pictureHolder:Sprite = new Sprite();
var picture1:Bitmap = new Bitmap();
var picture2:Bitmap = new Bitmap();
var picture3:Bitmap = new Bitmap(); = "pic1"; = "pic2"; = "pic3";
pictureHolder.addChildAt(picture3, 2);
trace(pictureHolder.getChildAt(2).name); //outputs: pic3

As you can see, it was very easy to add the picture3 Bitmap Object to the 2nd index of the pictureHolder's child list. The other great thing about this method is that even though we placed picture3 in the same index as picture2, we did not overwrite the existence of picture2 as a child. Instead, picture2 was automaticly moved one up in the child index. Yet again, this would have been much harder to accomplish in AS 2.0/1.0. More kudos to 3.0!!