Flash don’t got no rhythm! - Making an accurate Tempo system with actionscript
I have been working on a rhythm game that combines sequencing with looping and I have to say that flash is one of the most rhythmically challenged things I’ve ever come into contact with, including the drummer from my first band… but I have found some ways around it!
My initial idea was to trigger a sound with the sound.start(); function every time a loop finished, but since Flash is less than perfect, it introduces a random length gap just long enough to cause a problem, meaning the loops are not seamless, as it has to do some calculating before it plays the loop again.
So this has led me to my new method - I have used actionscript to split the 4 bar loop into 8 half notes. I took the sound.duration() value, divided it by 8 (for the half notes), and stored each multiple of the note in an array. Each frame I check the array, and if the sound.position() value is plus or minus a margin of error close to any of those multiples, it must be on the beat - then I can tell it to do things.
Though this is still not perfect - I am at current refining this method, but thought I’d share it with the rest of the internet!
Any other suggestions as to how to keep flash in time? Share them with a comment below!
Posted
on
Monday, November 10th, 2008 at 10:05 pm under

