I have searched the forum, and have not found the answer to this question:
I need to generate a 6 digit random number from Flash MX, then pass that number as a variable to an .asp page. I know how to pass the variable, but I’m not sure how to generate the number, then set it as a variable…
[AS]//create new array to store numbers
var storeArray = [];
//create new string variable
var myString;
//create for loop
for (var i = 0; i<6; i++) {
//in position of i in the array
//store a random number from 0 to 9
storeArray* = random(10);
//add that number to the end of the string
myString += String(storeArray*);
}
//trace the final string of numbers
trace(myString);[/AS]
Is that what you are looking for.
Fluid: That always has a chance of returning a number less than 6 digits.
I think Im missing something here as well… we all know that math.round(Math.random) by itself does not produce random numbers that cover the whole spectrum of your range…
ahmed: your code sometimes returns a 3, 4, or 5 digit number instead of a six. 4 out of 10 tries returned a number that was not 6 digits. Lost’s way ensures that it will be 6 digits long, every time.
I’ll post the formula I like to use tomorrow, and it will always return a number within the correct range including the minimum and maximum number… if I think hard enough, I could just whip it out (the formula)… but Im not gonna… gonna go beddie bye bye. Oh and oooonee mre thhba.a…***;dddd …kjsf…
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
I think I will work on actual design of my site tonight instead of coding. I don’t want to screw up the progress I have thus far by being stupid in my coding