我想知道如何在鼠标按下时继续播放声音,例如发射机枪子弹(不单击),当声音结束时,我希望单击重新播放声音吗?
最佳答案
声音的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/