AS3 setChildIndex to front
18,341
Solution 1
You can use setChildIndex()
with numChildren
.
setChildIndex(childClip, numChildren - 1);
Solution 2
You don't need to use setChildIndex. addChild is sending child on the top of all clips. You may be thinking that addChild will double add your MC, but it will not, the second time it will just update it's child index.
Author by
FoxLift
Updated on June 11, 2022Comments
-
FoxLift almost 2 years
Is there a way to send a specific movieClip to the front of all other movieClips on stage?
I know about setChildIndex, but I can't figure out a way to to calculate the top position dynamically.
-
Florent over 11 years
0
is the lowest level as every child is over. -
FoxLift over 11 yearsYes, that didn't work. That specifically sent my MovieClip to the back.
-
FoxLift over 11 yearsI'm not doubting that works, but that sounds overly complex, comparing to the" setChildIndex(childClip, numChildren - 1); " solution, given by Florent.
-
Neal Davis almost 8 yearsI like this solution for its simplicity. And it is very true. It will just update the index.