2010-04-04 73 views
0

不止一次地播放,導致回聲,我無法停止我的MP3播放器。 什麼是MP3播放的最佳做法?mp3播放停止回聲,as3

  var mySound:Sound = new Sound(); 
    playButton.addEventListener (MouseEvent.CLICK, myPlayButtonHandler); 
      var myChannel:SoundChannel = new SoundChannel(); 

      function myPlayButtonHandler (e:MouseEvent):void { 
        myChannel = mySound.play(); 
          } 
    stopButton.addEventListener(MouseEvent.CLICK, onClickStop); 
      function onClickStop(e:MouseEvent):void{ 
          myChannel.stop(); 
          } 

回答

1

這裏有兩個按鈕用於全局控制音量。讓我知道如果這不起作用。

var mySound:Sound = new Sound(); 
playButton.addEventListener (MouseEvent.CLICK, myPlayButtonHandler); 
var myChannel:SoundChannel = new SoundChannel(); 
     function myPlayButtonHandler (e:MouseEvent):void { 

      myChannel = mySound.play(); 
      } 
stopButton.addEventListener(MouseEvent.CLICK, onClickStop); 
     function onClickStop(e:MouseEvent):void{ 
      myChannel.stop(); 
      } 

/*-----------------------------------------------------------------*/ 
//global sound buttons, add instance of 'killswitch' and 'onswitch' to stage 
killswitch.addEventListener(MouseEvent.CLICK, clipKillSwitch); 
     function clipKillSwitch(e:MouseEvent):void{ 
var transform1:SoundTransform=new SoundTransform(); 
transform1.volume=0; 
flash.media.SoundMixer.soundTransform=transform1; 
      }  
onswitch.addEventListener(MouseEvent.CLICK, clipOnSwitch); 
     function clipOnSwitch(e:MouseEvent):void{ 
var transform1_:SoundTransform=new SoundTransform();   
transform1_.volume=1; 
flash.media.SoundMixer.soundTransform=transform1_;  
      } 
0

我會做幾件事。

  1. 一旦播放命中,將該狀態記錄在一個變種。然後,如果他們再次擊球,如果你已經處於「比賽」狀態,則不要做任何事情。

另一種選擇: 2.將播放按鈕更改爲暫停按鈕。然後,如果按鈕被擊中,則執行停止操作。如果他們然後暫停,然後將按鈕切換回來播放。