flash - 如何使计时器准确? (闪光灯/ ActionScript 3.0)

标签 flash actionscript-3 actionscript timer

我正在使用以下方法在 X 次/分钟内发送声音(X 是通过 bpm 确定的,它是一个 NumericStepper 对象)

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/声音不太好。我能做些什么来解决我陷入的这个问题吗?

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

最佳答案

http://cookbooks.adobe.com/post_Accurate_timer-17332.html可能对你有帮助。

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.

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.

关于flash - 如何使计时器准确? (闪光灯/ ActionScript 3.0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5955044/

相关文章:

javascript - 如何识别调用 Javascript 函数的第 3 方 Flash 对象?

actionscript-3 - 这是 Actionscript 3 中 MVC 的正确实现吗?

apache-flex - 将多个 SWF 文件转换为单个 EXE

actionscript-3 - 在 AS3 中将 alpha 百分比转换为 RGBA 十六进制?

flash - 如何在 actionscript 3 中计算给定十六进制颜色的阴影?

file-upload - 文件上传和 swf 转换工具 - 类似于幻灯片共享

algorithm - 我的 A* 寻路实现不产生最短路径

flash - 在某些浏览器中外部加载的声音回声

flash - 计算一个字母包含在字符串中的次数

objective-c - 独立的实时输入音频可视化器应用程序使用哪种语言/API?