Random Number - ActionScript 3
31/10/2008
When we develop often need Randoms numbers, whether to display random photos, lists of users, etc ...
For this i developed a class to handle the Math.random () between two numbers and make this task easier.
let's see how it works:
import phoxer.Numbers.Random; Random.getRandom(10,20); //19.288095352239907 Random.getRandom(10,20,true); //15 trace(Random.getRandom(-10,-20); //-13.606321583501995 trace(Random.getRandom(-10,-20,true); //-12
The first parameter is the number lower.
The second parameter is the number higher.
The third parameter indicates whether it is to be strict or not.
My Random full class:
/** by .:{PHOXER}:. http://www.phoxer.com v 2.5; */ package phoxer.Numbers{ public class Random{ public static function getRandom(min:Number,max:Number,estrict:Boolean=false):Number{ var rand:Number= Number(Math.random() * (max - min) + min); return (estrict)? Math.round(rand):rand; } } }
