I don’t know why this never occured to me before, but as I was checking out AS2 I came across the new MovieClip methods getNextHighestDepth and getInstanceAtDepth. Since they are only available in Flash Player 7, I wrote them out for Flash Player 6:
bc[as]. MovieClip.prototype.getNextDepth = function() {
var depth = 0;
for (var prop in this) {
if (typeof this[prop] == “movieclip”) {
trace(”depth = “+this[prop].getDepth());
var newDepth = this[prop].getDepth();
if (newDepth>depth) {
depth = newDepth;
}
}
}
return depth+1;
};
bc[as]. MovieClip.prototype.getClipAtDepth = function(depth) {
for (var prop in this) {
if (typeof this[prop] == “movieclip”) {
if (this[prop].getDepth() == depth) {
return this[prop];
}
}
}
};