加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex – AS3中准确的BPM事件监听器

发布时间:2020-12-15 02:13:12 所属栏目:百科 来源:网络整理
导读:我正在尝试将动画同步到特定BPM的音乐.我尝试过使用Timer但是在处理小间隔时(毫秒)并不准确.我做了一些阅读,发现了另一种使用小型静音音频文件和SOUND_COMPLETE事件作为计时器的方法. 我用这段代码用了167ms长的声音文件. package{ import flash.events.Even
我正在尝试将动画同步到特定BPM的音乐.我尝试过使用Timer但是在处理小间隔时(毫秒)并不准确.我做了一些阅读,发现了另一种使用小型静音音频文件和SOUND_COMPLETE事件作为计时器的方法.

我用这段代码用了167ms长的声音文件.

package
{
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;

    public class BetterTimer extends EventDispatcher
    {
        private var silentSound:Sound;

        public function BetterTimer(silentSoundUrl:String):void {
            super();
            silentSound = new Sound( new URLRequest(silentSoundUrl) );
            silentSound.addEventListener(Event.COMPLETE,start);
        }
        public function start():void {
            this.timerFired( new Event("start") );
        }
        private function timerFired(e:Event):void {
            dispatchEvent( new Event("fire") );
            var channel:SoundChannel = silentSound.play();
            channel.addEventListener(Event.SOUND_COMPLETE,timerFired,false,true);
        }
    }
}

这仍然没有留下来. Flash Player是否具有声音准确性?

解决方法

这是非常棘手的正确!有一个名为 BeatTimer的小型lib试图这样做.我自己没有尝试过这个代码,但是如果它做了它声称它应该正是你需要的东西.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读