actionscript-3 - 闪光枪模拟

标签 actionscript-3 audio loops actionscript reload

我想知道如何在鼠标按下时继续播放声音,例如发射机枪子弹(不单击),当声音结束时,我希望单击重新播放声音吗?

最佳答案

声音的play方法中的第二个参数是循环计数。您可以为此指定一个较大的值。 play方法返回SoundChannel对象。在鼠标向上听众中,您可以使用此SoundChannel的stop方法停止声音。

// instance variable to remember the channel
private var channel:SoundChannel;

private function onMouseDown(evt:MouseEvent):void {
    // remember channel and start looping
    channel = snd.play(0, 1000000);
}

private function onMouseUp(evt:MouseEvent):void {
   // stop the sound stated in mouse down 
   channel.stop();
}

关于actionscript-3 - 闪光枪模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8976968/

相关文章:

algorithm - 在绘图引擎中查找交叉线

apache-flex - 错误#2099 : The loading object is not sufficiently loaded to provide this information

python - 猜谜游戏循环中倒计时的机会

java - 检查集合的元素是否有多个整数

actionscript-3 - as3 : does array splice delete an object completely?

actionscript-3 - as3 AIR Win- 在全屏窗口中阻止 ALT+空格键

python - 如何在 Python 脚本的后台播放音频(playsound)?

vb.net - 音频文件类

audio - Asterisk :WebRTC无音频

c++ - 如何返回指向数组中对象的指针?