Hi,
A friend composed some sound for my website. We split it into 11 pieces in a way that they can be played in random order. For now I'm working on the randomizer, therefore I have the sounds imported (I'll do the external loading later) and did the linking settings including id.
first: i read somewhere that i can create only 8 sound objects. is that ture? if so, i will have him got the piece into 8 parts not 11.
second: i think i got a way i can play them at random order now. but for some reason, there's an error. i trace the random numer and in which soundCompleted function it is generated. nevertheless, it always just plays track 7, although the trace comes from another 'soundCompleted handler'. here's the code. i know, this might be done more compact, but anyway:
firstSound = new Sound();
firstSound.attachSound("sound1"
secondSound = new Sound();
secondSound.attachSound("sound2"
thirdSound = new Sound();
thirdSound.attachSound("sound3"
forthSound = new Sound();
forthSound.attachSound("sound4"
fifthSound = new Sound();
fifthSound.attachSound("sound5"
sixthSound = new Sound();
sixthSound.attachSound("sound6"
seventhSound = new Sound();
seventhSound.attachSound("sound7"
eighthSound = new Sound();
eighthSound.attachSound("sound8"
firstSound.start(0,1);
firstSound.onSoundComplete = function() {
auswahl = (random(9));
trace("Von firstSound " + auswahl);
firstSound.stop();
switch(auswahl) {
case 1: firstSound.start();
case 2: secondSound.start();
case 3: thirdSound.start();
case 4: forthSound.start();
case 5: fifthSound.start();
case 6: sixthSound.start();
case 7: seventhSound.start();
case 8: eighthSound.start();
default: firstSound.start();
break;
}
}
secondSound.onSoundComplete = function() {
auswahl = (random(9));
trace("Von secondSound " + auswahl);
secondSound.stop();
switch(auswahl) {
case 1: firstSound.start();
case 2: secondSound.start();
case 3: thirdSound.start();
case 4: forthSound.start();
case 5: fifthSound.start();
case 6: sixthSound.start();
case 7: seventhSound.start();
case 8: eighthSound.start();
default: firstSound.start();
break;
}
}
.
.
.
it continues on until eighthSound similarly. The code is copy&pasted. I also checket the .Sound.stop() functions, especially in seventhSound, but it seems to be ok. here:
seventhSound.onSoundComplete = function() {
auswahl = (random(9));
trace("Von seventhSound " + auswahl);
seventhSound.stop();
switch(auswahl) {
case 1: firstSound.start();
case 2: secondSound.start();
case 3: thirdSound.start();
case 4: forthSound.start();
case 5: fifthSound.start();
case 6: sixthSound.start();
case 7: seventhSound.start();
case 8: eighthSound.start();
default: firstSound.start();
break;
}
}
Would be greatful for help.
Adrian
A friend composed some sound for my website. We split it into 11 pieces in a way that they can be played in random order. For now I'm working on the randomizer, therefore I have the sounds imported (I'll do the external loading later) and did the linking settings including id.
first: i read somewhere that i can create only 8 sound objects. is that ture? if so, i will have him got the piece into 8 parts not 11.
second: i think i got a way i can play them at random order now. but for some reason, there's an error. i trace the random numer and in which soundCompleted function it is generated. nevertheless, it always just plays track 7, although the trace comes from another 'soundCompleted handler'. here's the code. i know, this might be done more compact, but anyway:
firstSound = new Sound();
firstSound.attachSound("sound1"
secondSound = new Sound();
secondSound.attachSound("sound2"
thirdSound = new Sound();
thirdSound.attachSound("sound3"
forthSound = new Sound();
forthSound.attachSound("sound4"
fifthSound = new Sound();
fifthSound.attachSound("sound5"
sixthSound = new Sound();
sixthSound.attachSound("sound6"
seventhSound = new Sound();
seventhSound.attachSound("sound7"
eighthSound = new Sound();
eighthSound.attachSound("sound8"
firstSound.start(0,1);
firstSound.onSoundComplete = function() {
auswahl = (random(9));
trace("Von firstSound " + auswahl);
firstSound.stop();
switch(auswahl) {
case 1: firstSound.start();
case 2: secondSound.start();
case 3: thirdSound.start();
case 4: forthSound.start();
case 5: fifthSound.start();
case 6: sixthSound.start();
case 7: seventhSound.start();
case 8: eighthSound.start();
default: firstSound.start();
break;
}
}
secondSound.onSoundComplete = function() {
auswahl = (random(9));
trace("Von secondSound " + auswahl);
secondSound.stop();
switch(auswahl) {
case 1: firstSound.start();
case 2: secondSound.start();
case 3: thirdSound.start();
case 4: forthSound.start();
case 5: fifthSound.start();
case 6: sixthSound.start();
case 7: seventhSound.start();
case 8: eighthSound.start();
default: firstSound.start();
break;
}
}
.
.
.
it continues on until eighthSound similarly. The code is copy&pasted. I also checket the .Sound.stop() functions, especially in seventhSound, but it seems to be ok. here:
seventhSound.onSoundComplete = function() {
auswahl = (random(9));
trace("Von seventhSound " + auswahl);
seventhSound.stop();
switch(auswahl) {
case 1: firstSound.start();
case 2: secondSound.start();
case 3: thirdSound.start();
case 4: forthSound.start();
case 5: fifthSound.start();
case 6: sixthSound.start();
case 7: seventhSound.start();
case 8: eighthSound.start();
default: firstSound.start();
break;
}
}
Would be greatful for help.
Adrian