getNextHighestDepth gotcha: Part Deux

Via Ryan.

Blogspammers managed to break and foobar my MoveableType commenting system while I was on vacation for 2 weeks. However, comments like this remind me why I slave so hard to ensure it’s easy for readers to comment on my blog.

Since commenting is currently disabled till I fix it, here is the comment that got lost in a black hole, but brought to light a reason behind a problem I was having.

*******

This was driving me nuts, too. The answer is here. The long and short of it is if you are
using a button component in your movie and create, duplicate, or attach a
movieclip using _root.getNextHighestDepth(), the movieclip’s depth will be
1048576, at which depth the mc.removeMovieClip() method will not remove the
clip. It is important to remember that other components rely on the button
component for functionality, and so components like UIScrollBar will also
trigger this bug. In addition, the component does not have to even be on
stage; having the component present in the library is enough to provoke this
behavior.

2 Replies to “getNextHighestDepth gotcha: Part Deux”

  1. Ugh. Thanks for (re)posting this — it answers why my code suddenly stopped working once I added a simple little CheckBox component.

    So far Flash components are 0 for 3 in my finding them worth using…

  2. The Flash components for v2 rock, but they DO take a lot of learning which you shouldn’t have to do.

    Quick survival tips:
    – don’t code stuff on _root; make a class, and have 1 line of code that instantiates your class. That way, you won’t have ANY depth problems.
    – extend from either UIComponent or View; do not extend from movieclip. If your going to use the coponents, use all fo them.
    – Finally, do NOT lay out things by hand; use code in createChildren… you’ll have no initialization issues when doing this

    I could write a book, that but that should keep you out of harms way.

Comments are closed.