Play a random sound in flash.?

  • Thread starter Thread starter max
  • Start date Start date
M

max

Guest
Hays,
I am using actionscript 2 in Flash CS3 and I would like to know how to make actionscript play 1 of 3 sounds at random. So when you click a button it will play 1 sound out of a possible 3. Does anyone have a code for this?
 
You could use a math random script. I could make one for you once I'm done with something else I halft to do. xD

//Add this to the button
//Make sure its a button
on(release){
this.gotoAndPlay(Math.round(Math.random()*3)))
//Assuming theres 3 songs on each frame
//Make sure theres a stop(); function in each frame of the button
}

Hope this works. I just made it from scratch :P
 
Back
Top