Functional Get Random Point in a Rectangle


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



Copy this code and paste it in your HTML
  1. public function getRandomPoint(rectangle){
  2. var randomX = getRandomInteger(rectangle.left, rectangle.right);
  3. var randomY = getRandomInteger(rectangle.top, rectangle.bottom);
  4.  
  5. return new Point(randomX, randomY);
  6.  
  7. function getRandomInteger (min, max) {
  8. return min + Math.floor(Math.random()*(max + 1 - min));
  9. }
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.