Copy link to clipboard
Copied
When I use addChildAt, it adds the MC to the bottom of the list of the depth I specify. Is there a way to make this do the opposite? As in, make it so that it adds the MC above the depth of all the MC's in the depth specified? Thank you.
Copy link to clipboard
Copied
Hi.
Can you show us your code?
Regards,
JC
Copy link to clipboard
Copied
Sure thing:
var grunt:Grunt = new Grunt;
addChildAt(grunt,under_hud);
"under_hud" refers to directly underneath the game's HUD, which I have in a seperate code in an attempt to manage the depth, right here:
setChildIndex(cursor, numChildren -1);
under_cursor = getChildIndex(cursor) - 1;
setChildIndex(pause_screen, getChildIndex(cursor) -1);
setChildIndex(hud, getChildIndex(pause_screen) -1);
under_hud = getChildIndex(hud) - 1;
So what this is supposed to do is set the game's cursor to be the top MC at all times, and then below that is the pause screen when the pause button is pressed, and below that is the HUD.
Copy link to clipboard
Copied
use:
function addToTopF(_parent:DisplayObjectContainer,_child:DisplayObject):void{
_parent.addChildAt(_child,_parent.numChildren);
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now