10 Replies Latest reply on Sep 23, 2006 4:44 AM by Rothrock

    Overlapping buttons

    Stefan_Lesik
      Hi, I'm trying to create buttons that enlarge and reveal more content in the mouse over state. However the buttons do not overlap correctly because they are arranged at different levels, ie. some are in front and some are behind each other. Is there a script I can use that brings the enlarged image to the front when the user rolls over them? Thanks in advance.
        • 1. Re: Overlapping buttons
          Rothrock Level 5
          In the movie clip class there is the swapDepths() method. Personally I haven't used buttons for a long time – instead I prefer to define mouse events for movieclips.

          If you have to use buttons I think there is a secret way to apply the swapDepths() method to the button class as well. But I can't remember it off the top of my head. Search the forums a bit and maybe you will find it. When I get home tonight I will check for it on my machine.
          • 2. Re: Overlapping buttons
            Juankpro Level 2
            First of all, for that to work buttons must not be buttons, but movieclips acting like buttons, then for this buttons add this rollover (button name btn)):

            btn.onRollOver = function(){
            this.savedDepth = this.getDepth();
            this.swapDepths(5000);
            };
            btn.onRollOut = function(){
            this.swapDepths(this.savedDepth);
            };

            this roll over makes the button go to front and swap back where it was when rolled out. This must be done or your buttons will remain visible even if their timeline if no longer used.
            • 3. Re: Overlapping buttons
              Stefan_Lesik Level 1
              Im having problems with that script. Does anyone know of a good tutorial on swapDepth()? Thanks
              • 4. Re: Overlapping buttons
                Mister Peanut Level 1
                go to learnflash.com there is a new tutorial on this subject
                • 5. Re: Overlapping buttons
                  Mister Peanut Level 1
                  go to learnflash.com there is a new tutorial on this subject.
                  Looks like it's not free anymore... sorry. He did have one for exactly what you're looking for, though. I will let you know if I find something.

                  Brad
                  • 6. Overlapping buttons
                    Juankpro Level 2
                    The script I send you is pretty simple. Not to get lost. But it requires some things:

                    1) The buttons must me movie clips and not buttons, so check that they are movie clips on the library and also check if the behavior of the instance is set to MovieClip ans not button (in the Property Inspector).

                    2) This way of writting code was used from Flash 6 and further, so check you are exporting your file for Flash Player 6 or older.

                    3) This way of writting code must not be placed on the button itself, the code must be written on the frame where the button is placed.

                    4) The movie clips must have an instance name this instance name is then used in the code too. See the previous example, it expects a button called btn but you can call your movieclip button any other thing but remember to change btn to the name you gave to your button (instance name).

                    These are all the requirements. I´ve used this code for years and never had any problems or bugs. It shouldn´t, its too short to have bugs.

                    If it is still not working then maybe your movie clip buttons are not well constructed

                    I uploaded an example here: Swap sample
                    • 7. Re: Overlapping buttons
                      Rothrock Level 5
                      Okay, I found it. You can do the swapDepths just like juankpro says, but you don't have to give up your buttons if you don't want. All you have to do is add the following line to your code:

                      Button.prototype.swapDepths = MovieClip.prototype.swapDepths;

                      That creates the swapDepths prototype for the button class which allows buttons to be swapped as well.
                      • 8. Overlapping buttons
                        Juankpro Level 2
                        Wow Rothrock that was amazing. I always wanted a button to do that. But your code means "A button can change depths but for a weird reason we Adobe (legacy Macromedia) have not included the function, you have to do it manually". I don't know what you think, but I think is really stupid that knowing the applications capability to swap buttons, and beeing so easy to implement, haven´t ever done it. The code is pretty logical, but I never tried it because I supposed the C++ implementation of the Button didn´t exposed the function for a logical reason (like "we can´t swap Buttons yet"). Geee how long will we be discovering incomplete or undocumented things. Just do it for the next version. Maybe the TextField class can do the same thing.
                        • 9. Overlapping buttons
                          Juankpro Level 2
                          By the way. How on earth does somebody discovers this. Just by default?
                          • 10. Re: Overlapping buttons
                            Rothrock Level 5
                            I believe that Jeckyl showed it to me in some thread long ago. So that is how I had an idea of what to google for. Since I couldn't remember the exact way to do it, I googled "button swapDepths" on google. The third page was this:

                            http://www.senocular.com/flash/tutorials/depths/

                            The funny thing is that I never use buttons and haven't for several years! It probably made sense back in the day when buttons couldn't have names to not have them be swapable. Then they just forgot to add that or some such and it really hasn't been much of a issue since I think a lot of folks use buttons less as their scripting skills improve – so there probably weren't so many requests for it to get "fixed." That would be my guess anyways.