10 Replies Latest reply on Jul 10, 2009 1:34 PM by Ned Murphy

    Problem with swapdepth on buttons

    efrazee

      Here is the situation. I am attempting to make a simple web navigation bar. I have two buttons that are overlapping each other. On the rollover I want the button that is in the back to be brought to the front. this is the script I have.

       

      on(rollOver)

      {
          tips_btn.swapDepths(home_btn.getDepth() + 1);
      }

       

      I have used trace to see what level they are on before and after but the numbers never change. Both always stay at the same level. This should be something simple and I am probably just overlooking something. Any help would be greatly appreciated, thanks in advance.

        • 1. Re: Problem with swapdepth on buttons
          Ned Murphy Adobe Community Professional & MVP

          If kGlad or someone else who might know comes along, maybe some light can be shed on this, but here's what I found.  I couldn't get the swapDepths method to work for Button symbols, but I could get it to work for MovieClip symbols using timeline coding.  I changed both items to MovieClips and used the code shown below.  The same code wouldn't work for them as Button symbols, so it may just be a MovieClip method (much like gotoAndPlay is not associated with buttons)

           

          tips_btn.onRollOver = function(){
          tips_btn.swapDepths(home_btn);
          }

          • 2. Re: Problem with swapdepth on buttons
            Rothrock Level 5

            For some very strange reason they never included the swapDepths method in the Button prototype. Addding this line at the very beginning of your timeline should solve it. I hardly ever use actual button instances so I haven't used this much. I can't promise that it won't create some other problems, but it shouldn't, i.e. at least in everyday usage.

             

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

             

            Of course I would really recommend not using buttons....

            • 3. Re: Problem with swapdepth on buttons
              efrazee Level 1

              Ned:

              When I convert them to movie clips the same exact thing happens as when they were buttons. There seems to be no change for me.

               

              Rothrock:


              When I toss that in at the beginning of my timeline it does some good. It brings the correct button to front however it leaves the "over" frame as well as the "down" frame there. So I get a button inside a button.

               

              The navigation bar I am designing consists of 4 playing cards. When it loads it looks like the cards are being "breasted", or what it would look like when someone is holding cards in their hand. Then on the rollover I want the card to get bigger and come to the front. When I do what Rothrock suggested it creates the bigger card then returns to the down frame and creates that inside of it. I am not too terribly particular on how I accomplish this, I just want to be able to accomplish it whether using buttons or movie clips. My flash/actionscript skills are not only minimal but are also rusty seeing as I haven't touched flash in years. Any suggestions as to how to accomplish this?

              • 4. Re: Problem with swapdepth on buttons
                Ned Murphy Adobe Community Professional & MVP

                When I did it with the movieclips the code attached tothe movieclip like you were using doesn't work, but the code I showed for the timeline does.

                • 5. Re: Problem with swapdepth on buttons
                  efrazee Level 1

                  Well maybe I am misunderstanding you. My flash lingo may not be very good. I added the code you provided into the first frame of my timeline for my scene referencing the two buttons (which are now movieclips). When I did this there was no change. I also tried adding the code into my second frame of each individual movieclip and there seemed to be no change. Sorry I am making this so difficult, I do really appreciate the help though.

                  • 7. Re: Problem with swapdepth on buttons
                    efrazee Level 1

                    I really truly do appreciate your help. I made an attempt to set mine up like the example you gave me and yet I must still be missing something because it still isn't responding. I uploaded it to http://web.ics.purdue.edu/~efrazee/cgt141/project1/test1.fla if you could take a quick look that would be fantastic.

                    Edmund

                    • 8. Re: Problem with swapdepth on buttons
                      Ned Murphy Adobe Community Professional & MVP

                      You don't have the instance names assigned to the movieclips.  The names you assign in the library are not the instance names.  Instnce names are assigned in the properties panel.  That allows you to reuse the same library item multiple time because you can assign it different instance names.

                      • 9. Re: Problem with swapdepth on buttons
                        efrazee Level 1

                        I got it thank you so much. That helped a ton. I can hopefully figure it out from here. Once again thanks.

                        • 10. Re: Problem with swapdepth on buttons
                          Ned Murphy Adobe Community Professional & MVP

                          You're welcome