I have 3 sounds that I would like to play, they are in my library.
I can play any of of them usingsoundName.start(0,1)
with开发者_StackOverflow社区 the code below:
firstSound = new Sound();
firstSound.attachSound("Sound1");
secondSound = new Sound();
secondSound.attachSound("Sound2");
thirdSound = new Sound();
thirdSound.attachSound("Sound3");
The trouble i am having is, how can i know when sound1 has finished playing so i can then play sound2 and then sound3 immediately after?
You can calculate frame number of the sound ending using the framerate and sound lenght.
After that you can call AddFrameScript(frameNum, function)
and add code to play next sound.
In fact there exists a way in AS2, using onSoundComplete:
soundFX = new Sound();
soundFX.loadSound("sound.wav", true);
//or, if your sound is already in the library,
//use soundFX.attachSound("librarySoundInstanceName");
soundFX.onSoundComplete = function()
{
//DO some action
/////////////
gotoAndStop("new12");
die();
newLevel();
}
精彩评论