Je reprends en anglais si ça ne t'ennuie pas

... even though it may be a pain for some readers
The goal of all this is precisely not to create a file that will loop for ever following the same cycle. With 3 or 4 loops I want to build a piece of several minutes and be able to change the current loop whenever I want, with code only.
What I want to do is more or less the same as the solution in this thread :
http://www.actionscript.org/forums/s...d.php3?t=32921
BUT : onSoundComplete doesn't fire immediately, so when I switch from one loop to another, there is a short silence that ruins my plans.
I've found a workaround, using setInterval : when the loop starts, I start waiting with the setInterval method a little less than the loop duration :
ActionScript Code:
waitFirstLoop = setInterval(function() {
clearInterval(waitFirstLoop );
firstLoop.stop();
secondLoop.start();
}, firstLoop.duration-50);
This way, I'm sure that there won't be a short silence, since the second loop starts 50 milliseconds before the end of the first one. In most of the cases, you won't notice that the second sound starts too soon, firstly because 50 ms is short, secondly, because this lap seems to compensate a short delay before the secondLoop actually starts : in most of the cases, the secondLoop starts at the right moment.
But : this 50ms delay is not a garantuee, sometimes it's too long and you really ear that the secondLoop starts too soon. If you set a shorter delay, you may ear a silence.

So I am still wondering how did they make it work in the above thread with the onSoundComplete method, since to me it does the same : the second loop doesn't starts at the exact time the first one stops.