2 Replies Latest reply on Sep 7, 2006 10:30 AM by southbeachbum

    z-order: jumping above all levels on event handler

    southbeachbum Level 1
      i've got buttons sitting in clips which all sit on different levels. on rollover, i want the button to jump over all the other clip's levels surrounding it. anyone?

      sbb
        • 1. Re: z-order: jumping above all levels on event handler
          Rothrock Level 5
          Oh. So many things wrong with that question. :) But we can work it out.

          Lots of folks mix up layers, levels, and depths. You didn't mention layers, but I will include them here just to head off any confusion there.

          Layers: These are used in the authoring environment to organize your artwork. They loosely control stacking order because lower layers in the timeline will be below other artwork. But layers are removed when publishing your swf. There is no way to control layers after you have published.

          _levels: These can be used when loading external swf files into the same instance of the Flash player. The first swf is always in _level0 (zero) subsequent _levels can range into the millions I believe, but most folks keep it close to home with things like _level10 or _level85 and such. Generally speaking _levels with higher numbers will be on top of _levels with lower numbers. (There is a way around this, but more in a moment.). So the lowest thing in _level5 will always be above everything in _level0 through _level4.

          Depths: There is an excellent tutorial on depths which you should read. http://www.kirupa.com/developer/actionscript/depths.htm Basically depths determine the stacking order of things. You can use the MovieClip.swapDepths() method to change that order. (Read the help files for how this works and a few related methods.)The method works in one of two ways.

          Clip1.swapDepths(Clip2);
          Clip1.swapDepths(1000);

          The first takes Clip1 and Clip2 and switches their depths so that Clip2 is now where Clip1 was in the stack and Clip1 is where Clip2 was.

          The second just takes Clip1 and moves it to a depth of 1000. To tell the truth I don't know what happens if there was already something at 1000, but I think it will be moved to where ever Clip1 came from. If nothing is at 1000 then no problem.

          But a similar idea to the stacking of levels also applies here. In this case you can't move something out of its parent. So lets say you have two clips on the main timeline and inside each of those clips there is another clip.

          Maintimeline:Clip1.notherClip1
          Maintimeline:Clip2.notherClip2

          So if Clip2 is above Clip1 on the main timeline there is no way that that notherClip1 can be brought above Clip2 or notherClip2. You would have to bring Clip1 above Clip2. Then all of its art and the artwork of all its child clips will be above Clip2. Makes sense?

          I don't generally use buttons, but with earlier versions of Flash the swapDepths() method was "only" for instances of the MovieClip() class. There was a workaround to make it work for the button class, but I can't quite remember it. If you really need it we can try and figure that part out.

          AND OH YEAH, I promised to mention the part about _levels. You can actually use the swapDepths() method with _levels to move an entire level above the other. So:

          _level0.swapDepths(_level1);

          Will put _level0 above _level1, but it doesn't change the name or anything. An I don't think you can check for it or anything. Seems like a whole can of worms to me…
          • 2. Re: z-order: jumping above all levels on event handler
            southbeachbum Level 1
            well thanks so much for that input, much appreciated. i fiddled around with your direction and found that when on rollover the depth is swapped, rollout won't work because it's level is swapped so its rollout instruction won't respond. there's a couple of ways around my issue but they're kind of half assed. oh well, the client won't know that.

            just in case you're a saint, this is the situation: 9 loaded clips on 9 levels form a grid of 125 uniform rectangles with 2 pixels between them. button/clip rollover states that involve moving outside the rectangle's 29x16 area move under its neighbors. i could place a grid of clips loaded on top of everything which the lower levels target. arranging that and making correct paths will be a *****. or i can work another rollover look and feel that works within my boundaries.