title: AS3 random point between two rectangles
body: <p>I'm making a top view zombie survival game in AS3. I want to spawn the enemies in waves defined by "frames", or the difference between a bigger rectangle and a smaller one within it, like a picture frame. Right now here is my code, which is pretty inefficient. I was wondering if there was a better way. This code doesn't work right either, all the enemies spawn in the bottom right of the screen:</p>
  
  <pre><code>    public static function waveOne():Point {
  
          var inner:Rectangle = Waves.WAVE_ONE_RECTANGLE_1;
          var outer:Rectangle = Waves.WAVE_ONE_RECTANGLE_2;
  
          var x:Number = Math.random();
          var y:Number = Math.random();
  
          x = x * outer.width;
          y = y * outer.height;
  
          trace(x + " " + y);
  
          if (((x &gt; outer.left &amp;&amp; x &lt; inner.left) || (x &gt; inner.right &amp;&amp; x &lt; outer.right)) &amp;&amp; ((y &gt; outer.top &amp;&amp; y &lt; inner.top) || (y &gt; inner.bottom &amp;&amp; y &lt; outer.bottom))) {
              return(new Point(x, y));
          }
          else {
              return waveOne();
          }
      }
  </code></pre>