This content has been marked as final.
Show 7 replies

1. Re: generate multiple random numbers?
kglad Jan 29, 2009 8:04 AM (in response to shintashi)define a function that generates a random number and call that function when you need. 
2. Re: generate multiple random numbers?
shintashi Jan 29, 2009 9:06 AM (in response to kglad)quote:
Originally posted by: kglad
define a function that generates a random number and call that function when you need.
I will give it a go.

3. Re: generate multiple random numbers?
shintashi Jan 29, 2009 9:29 AM (in response to shintashi)ok, i've got a half working version;
function ranbot(x) {
return Math.ceil(Math.random()* x) + "/" + Math.ceil(Math.random()* x);
}
trace(ranbot(60));
but is it possible to set up the function so the numerator is equal to or less than the denominator? Also, if the numerator is set to never exceed the denominator, then a large percentage  something like 2550% of the output fractions would equal "1", like 55/55, 23/23, 7/7, 28/28, and so on.
I did something like this when using variables;
var randombot2:Number = Math.ceil(Math.random()* 99);
var randomtop2:Number = Math.min(randombot2  Math.floor(Math.random()* randombot2* 0.5), Math.ceil(Math.random()* 99));
 but I do not understand how this works in function terminology. 

5. generate multiple random numbers?
clbeech Jan 29, 2009 10:12 AM (in response to shintashi)perhaps something more like:
function ranbot(val:int):String {
var de = Math.ceil(Math.random() * val);
var nu = Math.ceil(Math.random() * de);
return nu +'/'+ de;
}
PHAHAHAH! sorry kg  you beat me again! interesting though almost the same methods :) 
6. Re: generate multiple random numbers?
shintashi Jan 29, 2009 10:19 AM (in response to shintashi)wow!
those are both better compressed than my jury rigging below:
 horrible jury rigged version 
function ranbot(x) {
return Math.ceil(Math.random()* x);
}
function rantop(x) {
return Math.ceil(Math.random()* x);
}
calico = 0;
mercedes = 0;
mybutton_mc.onPress = function(){
twisttop = rantop(60);
twistbot = ranbot(60);
if(twisttop > twistbot){calico = twisttop; mercedes = twistbot}
if(twisttop < twistbot){calico = twistbot; mercedes = twisttop}
vill.text = mercedes + "/" + calico;
}
Domo Aregato! 
7. Re: generate multiple random numbers?
kglad Jan 29, 2009 5:29 PM (in response to shintashi)okkei!