Reputation: 4055
How do I make sure that a movie clip that starts on the stage has a higher zindex then when I addChild and add a linked movieClip from the library.
Really my code is pretty simple
background_image = new Sprite();
main_container.addChild (background_image);
But I have a movieClip "message_box" that I dragged onto the main timeline. When i add the background_image which is the full size of the stage it overlays the "message_box"
I know you can set the childs index but how do I set the "message_box" index?
Upvotes: 0
Views: 1333
Reputation: 9572
You can create a container for all the MCs you would like to have above your background image
var background:Sprite = new Sprite();
var container:Sprite = new Sprite();
var messageBox:MovieClip = new MovieClip();
addChild( background );
//will contain everything in between
addChild( container);
//The message will always be on top
addChild( messageBox );
//From then on, only use container to add children
var mc1:MovieClip = new MovieClip();
container.addChild( mc1 );
Upvotes: 0
Reputation: 39456
If you want your message_box
to be on the highest layer, just use this:
if(message_box.parent)
message_box.parent.addChild(message_box);
Most likely required whenever you use addChild()
to add new elements to the stage.
Alternatively just make a container on a lower layer than the message_box
and add all of your children into that.
Upvotes: 2