I am trying to do a random sound on a on (press) event for a button. For the sounds “Be Quiet” and “Be Quiet2” I have modified the linkage and set the indentifier to the same names, also I checked “Export for action script” and “Export in first frame.” When I test the movie and click on the button, no sound happens. I am thinking it must be the script, can anyone help me? There might even be a reward involved. (well a mediocre award) BTW I am somewhat a beginer in this, so bear with me if I get a tiny bit confused. Here is my current code.
on (press) {
var X = Math.floor(Math.random() * (2 - 1)) + 1;
if (X = 2) {
mySound.attachSound(“Be Quiet”);
mySound.start([0]);
}
if (X = 1){
mySound.attachSound(“Be Quiet2”);
mySound.start([0]);
}
}
haven’t checked your mysound.attachSound code but your random is too complicated. You can use instead:
on (press) {
var i = Math.random();
if(i > 0.5){play your sound}else{play the other sound}}
[AS]on (press) {
var X = Math.floor(Math.random()*2)+1;
var mySound = new Sound();
mySound.attachSound(“Be Quiet”+X);
mySound.start();
}[/AS]Make your sounds linkage identifiers “Be Quiet1” and “Be Quiet2” (no quotes)
Thanks for your help. I got that random expression from one of the tutorials on this website. Claudio that did the trick, it works great, thank you. And for that reward thingy, to anyone that replied to this messenge (Avi, Uli, and claudio), I can do a logo or simple midi song for them. Just tell me what you would like done. You can see examples of my style at www.goremata.net