8 Replies Latest reply on May 5, 2009 9:04 PM by kglad

    Toggling between two button symbols

    theMikeD

      Hi there

       

      I am new to AS, but not new to programming.  I'm using Flash CS4.  Here is what I'm trying to do.

       

      I have two button symbols, PlayBTN and PauseBTN. They are used to control the playback of a slideshow. When I use either one or the other to control the slideshow, it works. However, what I want to do is toggle between the two buttons, so that they work together like this:

       

      1. If the slideshow is playing, PauseBTN is visible. If PauseBTN is clicked, the slideshow stops, and PlayBTN becomes visible.

      2. If the slideshow is paused, PlayBTN is visible. If PlayBTN is clicked, the slideshow stops, and PauseBTN becomes visible.

       

      In other words, clicking the button not only controls the slideshow, but changes which button is visible.

       

      I had this working using a two-frame movie clip and static bitmaps, but when I swap out the bitmaps for the buttons, the button rollovers stop working.

       

      Can anyone give me some guidance please?

       

      ...Mike

        • 1. Re: Toggling between two button symbols
          kglad Adobe Community Professional & MVP

          assign the visible property of those buttons in your mouse handlers.  if you don't understand how to do that, copy and paste your current mouse handlers.

          • 2. Re: Toggling between two button symbols
            theMikeD Level 1

            Thanks for the help, but I'm not sure what you mean, or how to check that.  I've looked through the UI for visibility things and don't really see any. I'm a bit out of my depth here

             

            Basically I have a movie clip with two frames. In frame one I have a instance of PauseBTN, and in frame two an instance of PlayBTN. Currently, when I click on this clip, the slideshow stops and plays appropriately, and the normal state of the button is shown.  It's just the rollovers that are not working.

             

            What can I provide you so that we can figure this out?

             

            ...Mike

            • 3. Re: Toggling between two button symbols
              kglad Adobe Community Professional & MVP

              that's not a flexible setup.  PauseBtn should be a movieclip with an up,over and possibly down frame and PlayBtn should be a movieclip with an up, over and possibly down frame.  you can then use:

               

              PauseBtn._visible = true;  // or false ot control your button's visible property.

              • 4. Re: Toggling between two button symbols
                theMikeD Level 1

                Both PlayBTN and PauseBTN are buttons, not movieclips, and each button has the three states set. Do you mean that I should recreate them as moviclips instead of buttons?

                 

                Assuming what I have is corrent, based on what you said, I should do the following:

                 

                1. Stack the two buttons one on top of the other. The PlayBTN instance is named PLAY and the PauseBT instance is named PAUSE.

                 

                2. Write code to set the initial visibility state of PLAY._visible to false

                 

                So when the SWF starts, PLAY is invisible, PAUSE is visible and the slideshow is playing.

                 

                3. write code so that PAUSE.onMouseUp() stops the slideshow, makes this._visible false, and PLAY._visible to true

                 

                So at this point, PLAY is visible and the slideshow is stopped.

                 

                4. write code so that PLAY.onMouseUp() starts the slideshow, makes this._visible false, and PAUSE._visible to true

                 

                Does that sound right?

                 

                ...Mike

                • 5. Re: Toggling between two button symbols
                  Ned Murphy Adobe Community Professional & MVP

                  What you describe in the case of using buttons should be fine.  If you use movieclips, then you also need to include code to direct the currently visible button/mc to the different frames for the different states.

                  1 person found this helpful
                  • 6. Re: Toggling between two button symbols
                    kglad Adobe Community Professional & MVP

                    1.  yes

                    2.  yes

                    3.  no.  don't use onMouseUp, use onRelease.

                    4.  "                                         "

                     

                    that should work.

                    1 person found this helpful
                    • 7. Re: Toggling between two button symbols
                      theMikeD Level 1

                      Thanks so much guys, that did the trick

                       

                      ...Mike

                      • 8. Re: Toggling between two button symbols
                        kglad Adobe Community Professional & MVP

                        you're welcome.