如何使一个计时器准确? (闪存/ ActionScript 3.0中)计时器、闪存、准确、ActionScript

2023-09-08 11:31:59 作者:你可爱的野爹

我用下面的方法来派遣的X倍声音/分钟(X是通过BPM来确定,这是中使用NumericStepper对象)

I'm using the following method to dispatch a sound in X times/minute (X is determined through bpm, which is a NumericStepper object)

var mainTimer:Timer = new Timer(60 / (bpm.value * 1000),0);
mainTimer.addEventListener(TimerEvent.TIMER, fl_TimerHandler,false, 0, true); 
mainTimer.start();

function fl_TimerHandler(event:TimerEvent):void
     {
        metroTransform.volume = vol;
        flash.media.SoundMixer.soundTransform = metroTransform;
        metroChannel = metro.play();
        mainTimer.delay = 60 / bpm.value * 1000;
      }

根据这一 http://www.metronomeonline.com/ 中的声音不坐好。有什么我可以做些什么来解决这个问题,我卡在?

According to this http://www.metronomeonline.com/ the sound is not sitting well. Is there something I can do to fix this problem I'm stuck in?

的路径输出文件我越来越: http://conatur.net/metroBig.swf

Path to the output file I'm getting: http://conatur.net/metroBig.swf

推荐答案

的http://食谱。 adobe.com/post_Accurate_timer-17332.html~~V 可能会帮助你。

问题   Timer类的两个事件之间的延迟取决于许多因素(FPS,内存,扮演影片剪辑结束即)。超时设置为计时器类的属性延迟只是近似所以需要有一种方法来增大所述定时器的准确度。

Problem The delay between 2 events of the timer class depends on many factors ( fps, memory, played movie clip end i.e. ). The timeout set to property delay of timer class is only approximate so there needs to be a way to increase the accuracy of the timer.

解决方案   我的解决方案,以提高精度是延长计时器类和强制定时器使根据自定义属性准确的更多的周期。以这种方式,计时器的2个事件之间的延迟将被设置延迟 - +准确/ 2。由于事件的上升取决于形式很多因素2事件之间的真正延迟是:延迟 - 精确/ 2,从flash播放器下一个发射事件

Solution My solution to increase the accuracy is to extend the timer class and force the timer to make more cycles depending of the custom property accurate. In this way the delay between 2 events of the timer will be set delay - + accurate /2. Because the rising of the event depends form many factors truly delay between 2 events is from: delay - accurate/2 to next fired event from flash player.