3 Replies Latest reply on Sep 10, 2009 1:38 PM by MarionMacDonald

    Problem with Depths


      I've been reading about getDepths and swapDepths but can't figure out which I get -16383 in response to the following:


      _root.holder.attachMovie("button","introButton", 10);


      I've also used this in the same piece of code and get the expected response:


      this.createEmptyMovieClip("container", 5);


      I'd appreciate some pointers.



        • 1. Re: Problem with Depths
          MarionMacDonald Level 1

          Sorry, that should be 'why' not 'which'

          • 2. Re: Problem with Depths
            Rothrock Level 5

            That would be because that is the depth of the thing you asked for. Flash does what we tell it to do, not what we want.


            I can't quite tell if you are confused by the really low negative number or that you expected it to return 10?


            You are asking for the depth of _root.holder, not the depth of _root.holder.introButton. Remember that attachMovie puts the newly attached movie inside the object you tell it to put it inside of.


            Addtionally here is a great trick. attachMovie returns a reference to the newly attached movie so you can do something like this:


            var myNewClip:MovieClip=_root.holder.attachMovie("button","introButton", 10);

            trace("the attached clip is: "+myNewClip)

            trace("its depth is: "+myNewClip.getDepth());


            If your confusing is over the really negative number....My guess is that holder is something you placed on the timeline at author time, right? Here is a great article about the differences in how Flash handles depths between timeline placed and code placed objects.



            • 3. Re: Problem with Depths
              MarionMacDonald Level 1

              Thank you so much for your reply.  Doh, I knew it would be something obvious.


              And yYes, I had come across that article.