2 Replies Latest reply on Feb 16, 2009 1:19 PM by Rothrock

    How do you change a button's depth?

      I have several buttons that reveal large blocks of text on rollover. I would like the current button being rolled over to be the topmost button so the text block isn't obscured by other buttons. getDepth() shows me the button's depth, however swapDepth() appears to only work with movie clips. Is there a way to dynamically change a button's depth?
        • 1. Re: How do you change a button's depth?
          kglad Adobe Community Professional & MVP

          use movieclip buttons.
          • 2. Re: How do you change a button's depth?
            Rothrock Level 5
            It is because for some silly reason the Flash builders forgot to give the Button class the swapDepths() method. Of course most folks don't actually use actual buttons, but instead use movieclips with mouse events. But if you must....


            Put that on the first frame of code you have, you only need it once in a swf. It assigns the MovieClip class's swapDepths method to Buttons (which in some convoluted way are just a special kind of movieclip).

            I've used it before and tested it quite a bit, and never had any problems. But that doesn't mean that it won't break something behind the scenes. So use it at your own risk.

            The only other solution is to wrap the buttons in movie clips and then swap the movies.