Monday, February 16, 2009

Actionscript: Custom Random Function

I made a custom random function in case you are looking for a random number generator in Actionscript. Actionscript has a random number function but it does not really allow you to specify a minimum and maximum range. Here is the code:

private function getRandomNumber(min:int, max:int):int
{
    var xRandomNumber:int;
    xRandomNumber= Math.floor(Math.random() * (max -1)) ) + min; 
   return(xRandomNumber);


} // getRandomNumber


0 comments: