Here is a little example for a metronome.
(see attached file)
The only thing that Flash has to do during the Interval is to play a sound.
In this case the sound is even uncompressed, so not much CPU Power is needed.
Now, if you type in for example 100 BPM in the first Inputfield and 130 BPM in the second, guess what, you don't here a difference...
And normally 100 vs 130 BPM is a BIG difference ( think seventies disco vs techno music)...
If you go lower, the a difference is there, but ist is far from the tempo it should have compared to a real metronome.
I don't know if this is a bug or just the way it is, but I think MM shouln't really use "milliseconds"(Forget using this as a means to build for example a halfway precise timer).
Just my two cents...
Ah, and maybe I did something wrong ...
So here's the code:
Code:
//create Sound Variables
rim = new Sound ();
rim.attachSound ("RIM");
clave = new Sound ();
clave.attachSound ("CL");
//the play functions
function playit ()
{
rim.start ();
}
function playitTwo ()
{
clave.start ();
}
//the functions that contains the Intervals
function Metronome ()
{
tempo = Math.round (15000 / (bpm));
clearInterval (inta);
inta = setInterval (playit, tempo);
}
function MetronomeTwo ()
{
tempoTwo = Math.round (15000 / (bpmTwo));
clearInterval (intaTwo);
intaTwo = setInterval (playitTwo, tempoTwo);
}
//the play buttons
buttonOne.onRelease = Metronome;
buttonTwo.onRelease = MetronomeTwo;
buttonBoth.onRelease = function ()
{
MetronomeTwo ();
Metronome ();
};
//the stop buttons
stopbuttonOne.onrelease = function ()
{
clearInterval (inta);
};
stopbuttonTwo.onrelease = function ()
{
clearInterval (intaTwo);
};
stopbuttonBoth.onrelease = function ()
{
clearInterval (inta);
clearInterval (intaTwo);
};
//updating the Interval Value on Input change
input.onChanged = function ()
{
tempo = Math.round (15000 / (bpm));
};
inputTwo.onChanged = function ()
{
tempoTwo = Math.round (15000 / (bpmTwo));
};