3 Replies Latest reply on May 29, 2007 8:54 AM by Rick Gerard

    Rearrange movie depth

    Rick Gerard Adobe Community Professional & MVP
      The problem I have is that my movies overlap when they play. I've created a successful script that is working for everything but depth. The script uses button hit spots to control the movies. Roll over the hit areas and the movies play.

      Movies are a simple animated still that scales up and moves to the right. Unfortunately, there isn't room to have the still move far enough to the right to get out of the way of the other 8 parked movies so the farther down the list you go, the more of the first frames obscure part of the movie.

      I'm using getNextHighestLevel but it isn't working as I would expect. All buttons are on the same layer, all movie clips are on different layers.

      Any suggestions would be appreciated. Here's a copy of the script so far.
        • 1. Re: Rearrange movie depth
          kglad Adobe Community Professional & MVP
          use the swapDepths() method of movieclips.
          • 2. Re: Rearrange movie depth
            Rothrock Level 5
            That is because you aren't expecting the correct thing. Check out getNextHighestDepth() in the help files. You will see it just returns a number that tells you what the next highest depth is. It doesn't put anything there or DO anything. So in this case it is telling you what the next highest depth inside a_mc is (most likely 0) and since you aren't assigning that to a variable it is lost and you are done.

            But that isn't the approach you even want. So let us look at something else. What you need is swapDepths() that actually does something.

            swapDepths() works two ways, you can give it two clips and it will swap them both. So something like this:


            Will switch the depths of the two clips mentioned there. However, both clips must be inside the same parent clip. So the both must be on the _root level or if clip1 is inside myMovies then clip2 must be inside myMovies and so on.

            The other way that swapDepths works is by just giving a number:


            Will put clip1 on depth 1000. If there is already something on 1000 it will go to where ever clip1 was before it was swapped to 1000. Again, all the clips you have will need to be in the same parent clip.

            You should only use positive depths and you have quite a few of them from 1 (they say you can use 0, but I don't) to a bit over 1,000,000 and really even higher, but you have to be careful. To learn everything about depths in Flash see this tutorial.

            • 3. Re: Rearrange movie depth
              Rick Gerard Adobe Community Professional & MVP
              Thanks... just used swapDepths(1); and it worked just great.

              Wish the help files were easier to search.