PDA

View Full Version : How to ake AS assets not to be on top layer


luka66_6
12-13-2008, 12:53 PM
I Have a bunch of layers on my stage (background, text, images....)and now i made a simple as3 animation with symbol that i pull from library put in to array and than animate a few of my symbols. My problem is that every time i do that these simbols are on very top of my assets regardless if i put as layer under background layer or wherever i put it. They are even over text and that is the biggest problem. Well i know if i make my text in as too i would easy control depth of symbols on stage but i am looking for alternative solution as i have my text animations all set up on timeline and there is a lot of them.

Suggestion are welcome
Luka

Sekhar
12-13-2008, 04:08 PM
If I understand you right, you're using addChild() and that's putting symbols at the top. This is normal, use addChildAt() instead to add at a specific depth. Alternatively, consider just making the symbols visible/invisible (set visible property to true/false).

batchas
12-13-2008, 07:30 PM
hello Luka,

You say you pulled this symbol from the library... The question is: do you mean you attached it (addChild()) or not?

If yes, as Sekhar said, the addChildAt() method should do it.
Like this:
addChildAt(yourMC, 0);

If not, you should name the symbol you would like not to be on top, and use these functions:

swapChildrenAt( index, index );
or
swapChildren( displayObject, displayObject );

Look for these functions here at actionscript,org.

Advice:
You have more control adding all your elements via script in AS3 (see display list).
You could make a movieclip or a sprite as container and then add all elements to this container.
Like this you would have full control on all of them on each level.

var container:MovieClip = new MovieClip(); // could be a sprite too, depending on its properties

container.addChildAt(element1, 1);
container.addChildAt(element2, 2);
container.addChildAt(element3, 3);

addChild(container);
or
addChildAt(container, 0);


Hope it helps!
batchas

luka66_6
12-14-2008, 07:07 PM
Tnx.

It helped. :)

Luka