gpt4 book ai didi

actionscript-3 - 如何在 ActionScript 3中重播声音

转载 作者:行者123 更新时间:2023-12-03 00:19:14 26 4
gpt4 key购买 nike

我正在尝试在游戏中重播此声音...但是由于某些原因,可以有人解释我为什么吗?

   var morning:Sound =new alarmclock ();
var transforming:SoundTransform = new SoundTransform(0.5);
var morningChannel:SoundChannel = morning.play(0,0,transforming);
morningChannel.addEventListener(Event.SOUND_COMPLETE, replay);
function replay (event:Event) {
morningChannel = morning.play(0,0,transforming);
trace ("ANYBODY IN THERE????");
}

最佳答案

做这个:

function replay (event:Event) {
morningChannel = morning.play(0,0,transforming);
trace ("ANYBODY IN THERE????");
morningChannel.addEventListener( Event.SOUND_COMPLETE, replay );
}

[Note we've added the event listener to the sound channel again. This is because the line "morningChannel = morning.play(0,0,transforming);" causes all event listeners on Sound Channel to be lost.]



我从 http://gamedev.michaeljameswilliams.com/2009/03/03/avoider-game-tutorial-9/借来了解释

关于actionscript-3 - 如何在 ActionScript 3中重播声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14699190/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com