Try this:
package util
{
public class RandomNumberHelper
{
public static function randomIntRange(start:Number, end:Number):int
{
return int(randomNumberRange(start, end));
}
public static function randomNumberRange(start:Number, end:Number):Number
{
end++;
return Math.floor(start + (Math.random() * (end - start)));
}
}
}
...
protected function testRandomIntsInRange(start:int, end:int):void
{
var randomIntsAssigned:Object = {};
var randomInt:int = 0;
for (var i:int = 0; i < 10000; i++)
{
randomInt = RandomNumberHelper.randomIntRange(start, end);
if (!randomIntsAssigned.hasOwnProperty(randomInt))
randomIntsAssigned[randomInt] = 0;
randomIntsAssigned[randomInt]++;
}
trace(randomIntsAssigned);
}
I am getting fairly even distributions between 0 and 9 at least.