4 Replies Latest reply on Dec 2, 2010 9:03 PM by danielmcooper

    SwapDepths and Button rollover problem

    danielmcooper

      HI! I'm currently working on a project (AS2 in CS5) that contains a lot of small dots that are set up as buttons with rollovers. This has been problematic since the rollovers will sometimes appear behind some of the other buttons.

       

      I did a forum search and found information about the swapdepths function that can be applied to buttons by using the following code:

       

       

      Button.prototype.swapDepths = MovieClip.prototype.swapDepths

       

       

      I also used the following code for my buttons:

       

       

      var origDepth:Number;

       


      name.onRollOver = function():Void{

      origDepth = this.getDepth();

      this.swapDepths(_root.getNextHighestDepth());

      }


      name.onRollOut = function():Void{

      this.swapDepths(origDepth);

      }

       

       

      This code solved the overlap problem, however... now when i roll out of the button, the "roll over" state remains visible (instead of returning to its original state)

       

      Would appreciate any help or feedback from anyone on how I can fix this problem.  Thanks!!!

        • 1. Re: SwapDepths and Button rollover problem
          Rothrock Level 5

          That is the problem with that hack. It hasn't been fully tested and it occasionally produces strange results.

           

          The first thing I would suggest is not using actual buttons. They are so twitchy and have so many strange little quirks that most folks I know stopped using them once you could put mouse events onto movieclips.

           

          So what happens if you remove the swapDepths from the rollout handler? Does that fix the state problem?

           

          Why are you swapping them back down anyways?

           

          Also it seems that you have multiple buttons, right? But it looks like you only one origDepth variables, so is there some kind of problem where when you rollout of one clip that you are rolling over another and the numbers are conflicting with each other?

          1 person found this helpful
          • 2. Re: SwapDepths and Button rollover problem
            danielmcooper Level 1

            I just tried removing the swapDepths from the rollout handler.  It did not fix the problem.

             

            How difficult is it to convert the buttons to movie clips and keep the content saved inside the rollover state for each of the buttons? I really don't want to start over if I don't have to since there are so many of them. (Over 100)

            • 3. Re: SwapDepths and Button rollover problem
              Rothrock Level 5

              Well it is probably too late to change them now, but for the future stop using buttons.

               

              So what happens if you remove all the swapdepths code? Do you still have the problem?

               

              It actually sounds like there might be something else causing the problem.

              • 4. Re: SwapDepths and Button rollover problem
                danielmcooper Level 1

                When I remove all the swapdepths code, the rollovers work again, but many of the rollover states appear behind the other buttons.

                 

                I just tried recreating a couple of the dots to movie clips with the swapdepths code and it works, and the rollovers appear above all the buttons.