I have two separate questions:
I have 8 different sound effects and a spinner list, in simpler terms, what do I need to do to assign 1 sound effect to each of the selections on the spinnerList, and then have the corresponding sound effect played when the user presses a button?
Secondly, what do I need to do to make it so that every time a dofferent button is pressed, it plays a random one of those 8 sound effects?
Some sample code would be great. Thanks.
I have figured out how to do the spinnerlist problem, Still in the dark about how to do the randomization.
The basic approach to picking something randomly:
// here's my array of items to choose from
var strings:Array = ["a", "b", "c", "d", "e", "f", "g", "h"];
// pick one of the items randomly
// Math.random() gets a random # n where 0 <= n < 1
// Multiply by array length to get a random index
// Math.floor() makes it an integer index where 0 <= n < Array.length
var s:String = strings[(Math.floor(Math.random() * strings.length))];