0
votes

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?

2

2 Answers

2
votes

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.

0
votes

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 );