PDA

View Full Version : Playing sounds sequentially



eurythmic
07-04-2008, 10:02 AM
Hi

For my MSc project I am trying to produce a piece of maths software for primary children using Flash and ActionScript 3.0. I need to be able to hook a string of sounds together to make a sentence, depending on what numbers the child has chosen, e.g. "three" "plus" "ten" "equals" "thirteen"
At the moment, when I try this, all sounds play at the same time, but I want each to start when the last has stopped. Anyone know how to achieve this? Putting them in an array is not ideal because the sequence is not fixed, but rather is dependent on the user input.

Any help would be much appreciated!

S xx

The_A
07-04-2008, 10:51 AM
hey,

i think you will have to use an array....

ground-concept:

pushing the numbers in an array,
create an array with the soundfiles,
create an array for the result

on click on the number, push the depending soundfile in your resultarray, plus the result of the calculation.

create a function which is recursive
something like this (UNTESTED AS 2 )



var count:Number = 0;

function playSounds(id:Number){
/* play sound from resultarray[id] */
/* when sound is done (you get this with onSoundComplete)*/
theSound.onSoundComplete= function() {
if(count<resultarray.length){
count++;
playSounds(count);
}
}

}


this is as 2, ther will be something simillar in AS 3

Hope it helps!
Regards,
A.