views:

96

answers:

3

If I use setChildIndex to change my movieclips index position on the stage. Can I only set it to a index that already been occupied. or can I make up an index of my own. like 100. Reason being is because I am trying to figure away to make movieclips always on top. What I had in mind besides setChildIndex is...

if(eApi.getChildIndex(this) < eApi.getChildIndex(target))
                eApi.swapGameChildren(this, target);

but before I use the above, I was checking to see if there is anything better. O yea, and "swapGameChildren" is just an encapsulated swapChildren() method.

+1  A: 

Use yourContainer.numChildren - 1 to get the topmost index.

grapefrukt
That is exactly what I did and it seems to work fine.
numerical25
+1  A: 

If you simply do an addChild then your asset will be placed on top. So if your asset mcA us under mcB and you addChild(mcA) it will move to the top position.

sberry2A
that seems like it would work but when you have enemies constanting spawning and dieing, the object you want on top seems to fall under
numerical25
It all depends on when you do your addChild call. Though, if you were doing it in the same place as what grapefrukt suggested then I don't see how it would be any different. But, glad it works anyway.
sberry2A
A: 

This is what I did

eApi.setChildIndex(this, (eApi.numChildren - 1));
numerical25