Journal Entries
Aug 10, 2005
Components vs. MovieClip.getNextHighestDepth()
The winner? MovieClip.getNextHighestDepth()! Every…ghat…damn…time!
Flash has an Actionscript command named ‘getNextHighestDepth()’. It is a method of the MovieClip class first included in MX 2000. It’s power is that it allows actionscripters to simply add or create movieClips on top of one another without keeping track of each movieClip’s depth. (movieClips created in a level already occupied by another movieClip will erase the latter…usually a bad thing.)
for (i=0; i<10; i++) {
this.createEmptyMovieClip( “mc_” + i, this.getNextHighestDepth() );
}
The preceeding code will create 10 empty movieClips each one level higher than the other. That’s all well and good but the advantage is that if I want to create more movieClips later, I can and I don’t have to know where to start adding movieClips on the screen.
But like all things Flash, there is a catch…one that may or may not be solved in the up-coming version 8. Any movieClip created with ‘getNextHighestDepth()’ is automatically placed over any component on the screen. And there is no way to switch that order.
The best explaination I read is that ‘getNextHighestDepth()’ depths exist somewhere outside of Flash’s normal depths. Therefore the the special depths are rendered after the normal depths.
This might seem like a small detail, but when you have already written a script that loads multiple movieClips at various times and depends on ‘getNextHighestDepth()’, it gets to be a problem.
Comments are closed.

