Record 3: Generating Random Numbers
function randRange(minNum, maxNum, decPl)
{
trace("random number between"+minNum+" and "+maxNum+ "is");
if(decp1==undefined)
decp1=0;
else
decp1=decp1;
var rangeDiff = (maxNum - minNum) * Math.pow(10, decPl) + 1;
var randVal = Math.random( ) * rangeDiff;
randVal = Math.floor(randVal);
randVal /= Math.pow(10, decPl);
randVal += minNum;
return Math.floor(randVal, Math.pow(10, -decPl));
}
trace(randRange(100,250,0));
Output
random number between100 and 250is