• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Rearrange movie depth

Community Expert ,
May 29, 2007 May 29, 2007

Copy link to clipboard

Copied

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.
TOPICS
ActionScript

Views

445

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2007 May 29, 2007

Copy link to clipboard

Copied

use the swapDepths() method of movieclips.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2007 May 29, 2007

Copy link to clipboard

Copied

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:

clip1.swapDepths(clip2);

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:

clip1.swapDepths(1000);

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.

http://www.kirupa.com/developer/actionscript/depths.htm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2007 May 29, 2007

Copy link to clipboard

Copied

LATEST
Thanks... just used swapDepths(1); and it worked just great.

Wish the help files were easier to search.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines