gotoAndPlay 声音结束后 as3

gotoAndPlay after sound ends as3

我希望我的时间轴在声音结束后前进到某个标记的帧。这是我到目前为止的代码:

var n1Channel:SoundChannel = new narratorAlphabetSounds();
n1Channel.addEventListener(Event.SOUND_COMPLETE, audioComplete);
function audioComplete(e:Event):void
{
gotoAndPlay("step2");  
}

声音加载失败,测试时出现错误。有什么建议么?谢谢!

你得到了隐式强制转换错误,因为你的 narratorAlphabetSounds 对象是一个 Sound object and not a SoundChannel ..然后播放你的声音并检测它何时完成播放,你应该使用 Sound 和一个 SoundChannel 个对象,像这样:

var sound:Sound = new narratorAlphabetSounds();

var sound_channel:SoundChannel = sound.play();
    sound_channel.addEventListener(Event.SOUND_COMPLETE, audioComplete);

function audioComplete(e:Event):void 
{
    trace('audio complete');
}

希望能帮到你。