【问题标题】:How do you keep repeating a song in AS3 FlashCS6?您如何在 AS3 Flash CS6 中不断重复歌曲?
【发布时间】:2013-11-02 22:57:31
【问题描述】:

我想知道您如何使用 AS3 在 Flash CS6 中一遍又一遍地重复歌曲?

目前我有这个代码:

var sound:Sound = new Sound(new URLRequest("YMCA.mp3"))
var soundChannel:SoundChannel = sound.play();

当这首歌一遍又一遍地完成时,我该如何重复?

非常感谢!

【问题讨论】:

    标签: actionscript-3 flash audio flash-cs6


    【解决方案1】:

    为你的 soundChannel 添加一个事件监听器:

    soundChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
    
    function soundCompleteHander(e:Event):void {
        sound.play();
    }
    

    【讨论】:

    • 我应该导入什么包?因为 soundCompleteHandler 有未定义的属性。嗯..
    • 导入 flash.events.Event;将导入 Event.SOUND_COMPLETE 但如果 Flash 没有发现 soundCompleteHandler 您(或我)可能输入错误...而且,确实,是的,我刚刚发现了错字。我会努力改正的。。
    • 我在函数名中遗漏了一个非常重要的“l”,抱歉。它应该是 soundCompleteHandler,而不是 soundCompleteHander
    【解决方案2】:

    这将使声音循环多次,播放完美无缺

    var sound:Sound = new Sound(new URLRequest("YMCA.mp3"))
    var soundChannel:SoundChannel = sound.play(0,999999999);
    

    【讨论】:

    • 感谢 Amer :)
    猜你喜欢
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    • 2012-11-20
    • 2013-11-03
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 2012-05-28
    相关资源
    最近更新 更多