Forum Moderators: open

Message Too Old, No Replies

Misbehaving layers

duplicateMovieClip creates objects on top of all layers

         

mike73

1:38 pm on Nov 1, 2006 (gmt 0)

10+ Year Member



I have a background layer on the bottom, a layer that only contains scripts in the middle, and a third, topmost layer that contains a few shapes. According to the documentaion, objects in the top layer should always be on top of objects in the other layers, and even if you have objects with really high depth in layer 2, objects in the top layer will always be over them.

Why then, do the objects created by my script using duplicateMovieClip always appear on top of all layers?

Mazoonist

2:12 pm on Nov 9, 2006 (gmt 0)

10+ Year Member



Hey, Mike,

First thing to realize is that in the published SWF there are no such thing as layers. They all get compressed, and the objects on them are assigned depths. And this is one way of controlling depths: Any object you want to have a higher depth than others, put it on a layer higher in the stack than the others.

The other way of controlling depths is to assign them yourself using Actionscript. That is what you are doing when you use duplicateMovieClip, as one of the required parameters is to give it a depth. If you're using getNextHighestDepth() for the parameter, your dynamic objects will always be on top of the authoring time objects, regardless of what layer your script is in.

You can control depths, however, whether they were created at authoring time or not. Any object that you'd like to be on top of everything else, just address it with code like this:

nameOfMovieClip.swapDepths(getNextHighestDepth());