I have a sprite and when it is added to the screen, I want it to be added on top of everything else on the stage.
What is the best way to ensure that a sprite when added, is on top of everything and not hidden behind other sprites?
Thanks,
~ kcg
Anytime you add a clip it is added on top by default.
So can use
addChild(Sprite);
or
addChildAt(Sprite,this.numChildren );
But if by any reason you are you are using flash/flex IDE & trying to keep the clip on the top of everything always & not really spawning them on the run, then I would suggest you to simply add the clip to the top most layer. But since you have tagged it as only actionscript the layer thing does not really exist here.
Also you might consider using swapchildren for already existing clips & swapping thier depths in the parent display object.
swapChildren(DisplayObject, DisplayObject);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With