How can I make an array in flash as2 and from there select 12 values assigning them to twelve different variables?
So far I got this:
quotes = new Array();
quotes[0] = "one";
quotes[1] = "two";
quotes[2] = "three";
quotes[3] = "four";
quotes[4] = "five";
quotes[5] = "six";
quotes[6] = "seven";
quotes[7] = "eight";
quotes[8] = "nine";
quotes[9] = "ten";
quotes[10] = "eleven";
quotes[11] = "twelve";
quotes[12] = "thirteen";
quotes[13] = "fourteen";
quotes[14] = "fifteen";
quotes[15] = "sixteen";
quotes[16] = "seventeen";
quotes[17] = "eighteen";
quotes[18] = "nineteen";
quotes[19] = "twenty";
Im keeping this structure because it will be easier to maintain in the long run and has more readability.
What I dont know is how to take twelve random values out of it and assign them to variables.
Ok, so I have now added this piece:
trace(quotes)
for(var i:Number = 0; i<12; i++){
var x:Number = Math.floor((Math.random()*quotes.length));
trace("X :: " + x);
trace("ARRAY VALUE :: " + quotes[x]);
quotes.splice(x,1);
}
Now I see in the trace 12 different values without repetition. But still I dont know how to make the results be the values of 12 different vars.
quotes[19] = "twenty";, maybe?