Forum Moderators: open
Why then, do the objects created by my script using duplicateMovieClip always appear on top of all layers?
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());