3 Replies Latest reply on Sep 7, 2011 9:10 AM by kglad

    Controlling Sound Within Buttons


      I have just recently purchased Adobe Flash CS5 and have read through the entire "Classroom In A Book" for Adobe Flash CS4 Professional.  However, the book never went into much detail into what I am trying to do.

      I'm creating a website for me and my fiance because we have formed a classical guitar and flute duo and want to exhibit some of our recordings.  I have the buttons for the recordings created with their corresponding sound file.  However, I cannot figure out how to stop the file when I click on another button recording; if I click all buttons, all sound files just keep playing simultaneously.

      Any advice would be greatly appreciated!!

      Thanks Everyone!

        • 1. Re: Controlling Sound Within Buttons
          kglad Adobe Community Professional & MVP

          use the sound class to play (and stop) your sounds.  if your sounds are attached to movieclip timelines, they're more difficult control and control is limited.  if they're attached to a button, they're impossible to control though you could use a global stop all sounds:


          stopAllSounds();  // as2

          SoundMixer.stopAll();  /as3

          • 2. Re: Controlling Sound Within Buttons
            ProTopazi Level 1

            Thanks for your response kglad!


            It has been quite a while since I have worked with Flash and I'm definitely new to ActionScript, so I don't really have any clue about the code that you posted.


            The sounds have not been placed in the timeline, but rather are referenced in the code.  There are only four buttons that play their corresponding files.  If I click one button, that sound file plays, but if I click another button, that sound file plays, but the previous sound file continues to play.  So if I end up clicking all four buttons, I have four sound files all playing at the same time.


            How can I get the previous sound file to stop when I click on a new button.


            Thanks again kglad for your response and any more help would be appreciated!

            • 3. Re: Controlling Sound Within Buttons
              kglad Adobe Community Professional & MVP

              just above lines of code where you start your sounds playing, add:


              stopAllSounds();  // if you're using as2

              SoundMixer.stopAll();  // if you're using as3