Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash 声音通道,移除Venthandler,AS3_Flash_Actionscript 3 - Fatal编程技术网

Flash 声音通道,移除Venthandler,AS3

Flash 声音通道,移除Venthandler,AS3,flash,actionscript-3,Flash,Actionscript 3,有没有更好的方法来使用AS3声道?这是可行的,但我讨厌当我点击播放按钮两次,它开始加倍。请告知 var mySound:Sound = new Sound(); playButton.addEventListener (MouseEvent.CLICK, myPlayButtonHandler); var myChannel:SoundChannel = new SoundChannel(); function myPlayButtonHandler (e:MouseEvent)

有没有更好的方法来使用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();
            }

/*-----------------------------------------------------------------*/
//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_;      
            }

只需使用
removeEventListener()
在声音持续时间内分离
myPlayButtonHandler

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

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

            }

/*-----------------------------------------------------------------*/
//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_;      
            }