3 Replies Latest reply: Apr 11, 2011 8:08 AM by kglad RSS

    Stop other sounds from playing while current sound is playing

    maxwellmb

      Hi

      I am creating a game that has 6 movieclips all on the main time line of the game.

      Each movie clip has three buttons that when clicked plays, pauses or stops a sound clip.

      When I press any of the sound clip play buttons that sound starts playing, the problem

      is when I click any of the other sound clip play buttons those sounds also start to play.

      Is there a way I can disable the other sound clip buttons while the current sound is

      playing then enable all of the buttons when the current sound has stopped.

       

      This is the code that creates one of the sound objects

       

      firstSound = new Sound(firstSoundMc);
      firstSound.attachSound("sound1");
      myMusicVolume=100;
      firstSound.setVolume(myMusicVolume);

       

      This is the code on the play button

       

      on (press) {
      //Sound is not playing and has not been paused
      if (playing!=true) {
      if (paused!=true) {
      playing=true;
      paused=false;
      stopped=false;
      firstSound.start(0,0);
      } //closes paused!=true
      //
      //Sound has been paused
      if (paused==true) {
      playing=true;
      paused=false;
      stopped=false;
      firstSound.start(myMusicPosition,0); 
      this.firstSound.onSoundComplete = function(){
      firstSound.start(0,0); 
      }
       
      } //Closes paused==true
      //
      //END
      }//Closes playing!=true
      //
      }//Closes on press

       

      Best Regards Maxwellmb