Random number with range


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function randomNumber(low:int = 0, high:int = 0):int{
  2. var low:int = low;
  3. var high:int = high;
  4.  
  5. if(low == high)
  6. throw new Error("low & high value must be the same");
  7.  
  8. return Math.round(Math.random() * (high - low)) + low;
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.