tags:

views:

47

answers:

2

I am adding child as:

containerComponent.addChild(newComponent);

But, it adds it as last child. How can I add newComponent as first child of containerComponent?

A: 

containerComponent.addChildAt(0, newComponent);

Neil
containerComponent.addChildAt(newComponent, 0);
Ok i got the params back to front, i think code hinting would have shown what is needed, i think its harsh to be marked down for that. Great way to promote knowledge sharing....
Neil
Yea, I agree ... its wrong to mark it down.
Agreed, not cool to mark it down. (Wasn't me.)
Wade Mueller
+4  A: 

Use addChildAt instead of addChild with the index parameter set to 0:

containerComponent.addChildAt(newComponent, 0);
Wade Mueller