title: Random bouncing balls in flash AS3 *Updated*
body: <p>UPDATE</p>
  
  <p>I now have this but only one ball bounces when the flash movie is run</p>
  
  <pre><code>var array:Array = new Array;
  
  var dx:Number = Math.random() * 20;
  
  var dy:Number = Math.random() * 10;
  
  var velX:Number = 5;
  
  var velY:Number = 5;
  
  
  addEventListener(Event.ENTER_FRAME, movearray);
  
  
  for (var i:Number = 0; i &lt; 20; i++) {
  
      var ball:Ball = new Ball();
  
      ball.x = Math.random() * 550;
  
      ball.y = Math.random() * 400;
  
      addChild(ball);
  
      array.push(ball);
  
  }
  
  
  function movearray(evt:Event):void {
  
      ball.x += velX;
  
      ball.y += velY;
  
      if (ball.x &gt; stage.stageWidth - ball.width / 2 || ball.x &lt; 0 + ball.width /2){
        velX *= -1;
      }
      else if (ball.y &gt; stage.stageHeight - ball.height / 2 || ball.y &lt; 0 + ball.height /2){
        velY *= -1;
     }
  }
  </code></pre>
  
  <p>Thanks any help appreciated. </p>