Well I am creating a project that involves music, and the flash should play a song and do something to it's beat...
I have the song's BPM (beats per minute) data, and it's stored as a variable.
I tried to animate something according to it using setInterval but I saw it doesn't sync perfectly.
To show the problem I just put the number 1000 in the milliseconds part.
intervalID = setInterval( callback, 1000 );
The output was:
and so on when each time it appears after approx. 1020-1040 milliseconds instead of exactly 1000
Why isn't it precise?! How can I make it sync perfectly??... [My song requires 400 milliseconds at a time..]
Is this command not rellevant?
setInterval isn't precise. to start, it only updates every frame interval so setInterval will only be as precise as the "real" fps.
Shouldn't functions that require MILLIseconds be precise?
NVM. Ok, but can you offer something instead of it???
I need something to be precise.
Something that would work like a clock, with a given number (milliseconds)
there's no way to get anything in flash to occur more precisely than within 10 or 20 ms and that's only possible in some situations.
the most accurate timing is realized using a high frame rate (that's real - ie, setting a high fps isn't enough) and using getTimer(). getTimer() is ms accurate.