i'm new with sounds in actionscript 3 and im having some troubles with detailed milliseconds project, which is very important it be accurate...
I'm running a sound which have a 'click' every 500 ms, i want to play other sound 250 miliseconds after the first one started... so, at first, i just tried to make all by the simplest way, with this:
import flash.display.MovieClip;
var som:som1 = new som1;
var som2:som2 = new som2;
som.play(0,100);
var myInterval:uint = setInterval(myFunction, 250);
function myFunction():void{
som2.play(0,100);
clearInterval(myInterval);
}
And it having a delay of 350 ms after first sound started...
So, in the second try i created a button for start/stop this code above... and i discovered is: On first time play, i got a 350 ms delay, but at the second time (after stop and play it again), it's working perfect, 250 ms as i wanted!
So, my solution was make a silent first play, without sound, just in background, for 'load' it, with this:
var firsttime:Boolean = true;
var transform1:SoundTransform = new SoundTransform();
transform1.volume = 0;
if (firsttime == true){
Som1Channel = som.play(0,1);
Som1Channel.soundTransform = transform1;
firsttime == false;
}
and it's working perfect... but that all was just test for main application, which is going to have a 25 seconds sound. And the user cant wait 25 seconds until sound starts.
Does anyone have other solution to this? The most important thing is to load the sound before it starts, is it possible? because it's already on my library, so, its not a loader case... Thanks!!