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.

Share:
18,341
FoxLift
Author by

FoxLift

Updated on June 11, 2022

Comments

  • FoxLift
    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
    Florent over 11 years
    0 is the lowest level as every child is over.
  • FoxLift
    FoxLift over 11 years
    Yes, that didn't work. That specifically sent my MovieClip to the back.
  • FoxLift
    FoxLift over 11 years
    I'm not doubting that works, but that sounds overly complex, comparing to the" setChildIndex(childClip, numChildren - 1); " solution, given by Florent.
  • Neal Davis
    Neal Davis almost 8 years
    I like this solution for its simplicity. And it is very true. It will just update the index.