title: Need help creating rocks to spawn on random location
body: <p>I'm making a Bullet Hell Shooter game on a basic standard level, I'm using AS3 and don't want to use any packages. I'm a game design student and my skills are really low. I been trying to look for falling rocks to spawn from different places, but all I get is like 10 rocks all in one rock and they don't re spawn after it goes off the screen.</p>
  
  <p>MY current code is:</p>
  
  <pre><code>    var background = new Background;
  
  background.x = 200;
  background.y = 200;
  
  addChild(background);
  
  var ship = new Ship
  
  ship.x = 125;
  ship.y = 350;
  
  addChild(ship);
  
  
  
  var rock = new Rock
  
  var result:Number = Math.random() * 100 
  var randomX:Number = Math.random() * stage.stageWidth
  rock.x = randomX;
  
  addChild(rock);
  
  addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_2);
  
  function fl_EnterFrameHandler_2(event:Event):void
  {
      rock.y +=5;
  }
  
  
  
  
  
  
  ship.gotoAndStop("normal");
  
  
  stage.addEventListener(KeyboardEvent.KEY_DOWN,fl_KeyboardDownHandler);
  
  function fl_KeyboardDownHandler(event:KeyboardEvent):void
  
  {
  
          if (event.keyCode == Keyboard.RIGHT)
  
          {
  
          ship.x +=5;
  
          }
            if (event.keyCode == Keyboard.LEFT)
  
          {
  
          ship.x -=5;
  
          }
  }
  
  stage.addEventListener(Event.ENTER_FRAME,detectCollision);
  function detectCollision(event:Event)
  {
           if(ship.hitTestObject(rock))
       {
           ship.gotoAndPlay("boom");
           ship.stop();
           stage.removeEventListener(KeyboardEvent.KEY_DOWN,fl_KeyboardDownHandler);
  
       }
  }
  </code></pre>