mp3播放停止回显,as3

时间:2010-04-04 19:41:49

标签: flash actionscript-3

多次击球,引起回音,我无法阻止我的MP3播放器。 mp3播放的最佳做法是什么?

            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();
                            }

2 个答案:

答案 0 :(得分: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_;      
            }

答案 1 :(得分:0)

我会做几件事。

  1. 一旦击中游戏,将该状态记录在变量中。然后,如果他们再次参加比赛,如果你已经处于“比赛”状态,就不要做任何事情。
  2. 另一种选择: 2.将播放按钮更改为暂停按钮。然后,如果按下按钮,则执行停止操作。如果他们然后点击暂停,则将按钮切换回来播放。

相关问题