Skip to main content
February 6, 2012
Question

Movieclip depth, changing on the fly.

  • February 6, 2012
  • 1 reply
  • 561 views

Ls (hi kglad),

Im trying to keep all my movieclips onto 1 layer/mother mc to speed up the flash display engine (as suggested by some adobe guru).

It works. but..

I have these takable items(movieclips) that respawn after a while.

Initially i build the level starting with all the takable items before adding all the players/npc's.

This way the player and npc's walk over the objects if they are not taken.

After an items respawns though, i have to re add them to the main mc and then they appear to be over the npc's and they seem to be moving under a carpet of stuff.

Its a nice 3d effect but totally unwanted in this scenario.

Is there a way to make sure that items are added as child before a certain clip (like the player).

I tried using addchildat but this gives me a index error now and then.

I dont really understand how the depths are worked out by flash.

I was thinking of storing the original depth of an item movieclip and then on restore, addchild at at its old depth.

Or is there a more sensible way?

Also: can two movieclips occupy the same index/depth level? or are the incemented or something?

Highest regards,

Mac

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 6, 2012

(i hope that isn't me being credited with an obviously false statement like, "..keep all my movieclips onto 1 layer/mother mc to speed up the flash display engine".)

anyway, if you want to add something to the top of the displaylist in a parent, use:

parent.addChild(something);

if you want to add something to the bottom of the display list in a parent, use:

parent.addChildAt(something,0);

if you want to add something betwen the top and bottom, you'll need to keep track of your depths or use some other artifice