2 Replies Latest reply on Dec 20, 2006 10:19 AM by Bob_Robertson

    detecting when sound has finished

    windsurf88 Level 1
      Looking for a method or statement or methodology ? that detects / knows when a sound is finished playing.

      here is a sound object for an remote mp3
      var mp3_sound:Sound = new Sound();
      mp3_sound.loadSound(" http://blablabla... thisfile.mp3", true);
      mp3_sound.stop();
      soundIsPlaying = false;

      A button using mp3_sound.start(); plays the sound from the start, goes to a frame witha pause button
      on (release) {
      /* get the current offset. if you stop all sounds and click the play button, the MP3 continues from where it was stopped, instead of restarting from the beginning. */
      var numSecondsOffset:Number = (mp3_sound.position/1000);
      if (soundIsPlaying == false) {
      if (mp3_sound.position == mp3_sound.duration) {
      stopAllSounds();
      mp3_sound.start();
      } else {
      mp3_sound.start(numSecondsOffset);
      }
      }
      gotoAndStop("play");
      soundIsPlaying = true;
      }
      The pause button works fine and toggles to the play button again to start at the new position.
      on (release) {
      stopAllSounds();
      soundIsPlaying = false;
      gotoAndStop("stop");
      }


      This works well but I would like it to return to the play button.


      how can a listener be used ? or something like that ... not sure.. as a while loop seems too ... well has many problems..

      Anybody have suggestions ?

      Thanks.