2 Replies Latest reply on Nov 12, 2007 8:21 AM by willja2001

    Music Loops

    willja2001
      I have a built in music player with several different tracks, after a song is complete it starts over and continues. I can not seem to stop the loop, any help would be much appreciated!
      here is my source.

      var numtrack = 1;
      var maxTracks = 3;
      my_sound = new Sound();
      my_sound.loadSound("music/track1.mp3", false);
      //
      my_sound.onLoad = function(ok) {
      if (ok) {
      clearInterval(interval);
      this.start();
      tf_txt.text = "";
      }
      };
      function loader(sound) {
      var gbl = sound.getBytesLoaded();
      var gbt = sound.getBytesTotal();
      tf_txt.text = "LOADING "+int(gbl/gbt*100)+"%";
      }
      my_sound.onSoundComplete = function() {
      my_sound.start();
      };
      interval = setInterval(loader, 100, my_sound);
      //
      // player controls
      btnNext.onRelease = function() {
      numtrack++;
      if (numtrack == maxTracks+1) {
      numtrack = 1;
      }
      my_sound.loadSound("music/track"+numtrack+".mp3", false);
      interval = setInterval(loader, 100, my_sound);
      trace(numtrack);
      };
      btnPrev.onRelease = function() {
      numtrack--;
      if (numtrack == 0) {
      numtrack = 3;
      }
      my_sound.loadSound("music/track"+numtrack+".mp3", false);
      interval = setInterval(loader, 100, my_sound);
      trace(numtrack);
      };
      btnStop.onRelease = function() {
      my_sound.stop();
      };
      btnPlay.onRelease = function() {
      my_sound.stop();
      my_sound.start();
      };