Posted By

publicbroadcast on 04/01/09


Tagged

actionscript3


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

goliatone


Functional Get Random Point in a Rectangle


 / Published in: ActionScript 3
 

  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  

You need to login to post a comment.