Hi, I’m sorry my first post has to be a query, but you can consider it a bug a report if you prefer. I cannot guarantee that this is not a mistake on my behalf, but I think after two days I’ve ruled out the possibility of a stupid mistake
I’ve run into the bizarre problem that onSoundComplete triggers before the sound is meant to have finished. Lemme explain the sample file, and why this behaviour is strange.
In a blank flash file (Flash 8), I add a single sound, and the following code:
var s=new Sound();
s.attachSound("one.wav");
s.onSoundComplete=function(){
trace(getTimer());
}
g=getTimer();
s.start();
trace(g);
trace(s.duration);
trace(g+s.duration);
My traced output is:
124
895
1019
878
I.e. onSoundComplete is running about 100ms earlier than you would think, given by the start time and sound duration. I could understand that onSoundComplete might finish early in order to help timing issues, but as far as I can tell from playing other sounds simultaneously, the sound **is **actually finishing at 1383ms, not 1478.
I have checked s.duration in Audacity, and it matches correctly to the ms. The import settings for the sound are the default, I’m importing it from a mono 22kHz WAV.
Worse, I get different results, but still strange ones, when using s.start(0) instead of s.start().
I cannot get the upload button to work (in ie or firefox), so if you want the fla, kindly download it from my website at http://adam.newgas.net/temp/bizzarre2.fla
Do other people get the same issue, and any thoughts on why it’s occuring?
PS:
[SIZE=1]In case you are wondering, I am attempting to make a component which, similar to [U][COLOR=#0000ff]http://sonify.org/tutorials/flash_audio/advanced/midisynth/[/COLOR][/U] , attempts to use a certain amount of silence at the beginning of the track and seeking in order to get accurate placement of sounds, in my case seamless looping. My component works great, but for some reason you can still here a seam between the first and second sounds played (but not the others, for some reason). I eventually tracked the problem down to this, as I was using setInterval(myFunc,sound.duration) instead of relying on onSoundComplete.[/SIZE]
[SIZE=1]PPS: Yes, that is my dopey voice saying “one”.[/SIZE]