5 Replies Latest reply on Jun 7, 2006 3:33 PM by Rothrock

# Movie Clip : Depth

Hello All,

I have one query regarding depth of movie clip object.After reading the document what i could understood is

1. Stage acts as a base in flash movie.
2. On stage we can create multiple movie clips at different depths.[different z factor]
3. next highest depth is retrieved by getNextHighestDepth() function.

My query is how flash handles depth inside movie clips i.e. if i say movieclip.getNextHighestDepth(), what happens
how depth is calculated.

Regards,
Ritu
• ###### 1. Movie Clip : Depth
1. Stage acts as a base in flash movie.
Yes (Unless you load THAT swf into another .swf which then adds another level below the one you are loading? Effectively you put your original box inside of another.)
2. On stage we can create multiple movie clips at different depths.[different z factor]
Yep (If you duplicate a Movieclip and add it to a level where there already exists a movieclip, then the original movieclip will disappear.)
3. next highest depth is retrieved by getNextHighestDepth() function.
Yes. (You can also ".swapDepths()" too)

From what I understand even if you dont name a movieClip then Flash will do it for you. There are effectively thousands of levels available starting from -16000 odd. Why it should start from a negative I have no idea.

I hope this is of some help.
• ###### 2. Re: Movie Clip : Depth

Just one more query..

how flash handles depth inside movie clips i.e. if i say movieclip.getNextHighestDepth(), what happens
how depth is calculated.

Thanks,
Ritu
• ###### 3. Re: Movie Clip : Depth
Here is a great tutorial about depths in Flash. There are actually millions of depths – but mostly just over one million that are what you should use.

http://www.kirupa.com/developer/actionscript/depths.htm

Within a movieclip the depths "start over" as it were. So if Clip A is below Clip B, all children clips inside A will all be below clip B. Or in other words is Clip A is at 50 and Clip B is at 51 and clip C (which is inside Clip A) is at 1,000,000. Clip C will still be below Clip B because it is a child of Clip A.

BTW, not that you asked but you do get what you pay for, I think getNextHighestDepth() is a totally lame thing to use. There are so many depths and so little likeliness that you will be attachinging or stacking more than 1,000 or 2,000 items. Design your file carefully and track the depths yourself.

If you use components they load something in at 1,048,576 (I think) and then getNextHighestDepth() is going to start returning numbers in a range that doesn't play well with a lot of commands and the timeline.
• ###### 4. Re: Movie Clip : Depth
I think negative depths are reserved for items that have been created on the stage
• ###### 5. Re: Movie Clip : Depth
Mostly correct. I guess it depends upon what you mean by reserved. Items placed on the stage are given negative depths, but they can be moved to positive depths and scripted artwork can be moved to negative depths. The results can be unpredictable/undesireable, but it can be done.

If you haven't read the kirupa tutorial above. It really lays out the whole thing for you!