0 Replies Latest reply on Jun 17, 2009 4:58 PM by lmcrun19

    Trying to use sound.close()

    lmcrun19

      I have a ComboBox connected to an ArrayCollection playing mp3's. When you switch to another mp3 in the ArrayCollection the first mp3 will continue to downloading while the second one is downloading also. I"m pretty sure you should do a "sound.close()" to get the first one to stop downloading. Basically, everytime the user switches sounds in the ComboBox I want the old sound to close and for the new sound to start. If anyone has any ideas I would love to hear them. Thanks in advance.

       

       


                  private function loadSound():void {
                      if(chan != null) {                   
                          chan.stop();
                      }               
                      sound = new Sound();
                      sound.addEventListener(Event.SOUND_COMPLETE, soundComplete);
                      var req:URLRequest = new URLRequest(server + cb.selectedItem.File);
                      sound.load(req);
                      pausePos = 0;
                      chan = sound.play();
                  }          
                  private function soundComplete(event:Event):void {
                      cb.selectedIndex++;
                      sound.load(new URLRequest(server + cb.selectedItem as String));
                      chan = sound.play();
                  }

       

                  private function playPauseHandler():void
                  {
                      if(pausePlayBtn.selected){
                          pausePos = chan.position;
                          chan.stop();
                      } else {
                          chan = sound.play(pausePos);
                      }
                  }