title: AS3 Calling Math.random in a scene?
body: <p>So, i'm trying to make a game where asteroids travel around randomly, but when I put my Math.random function outside of my function, it onlygives 1 value 1 time, and does not repeat each time the asteroid = 0. If I put it in my function, it just constantly updates and sends my asteroid flying around randomly. Any help? 
  EDIT: Sorry if I was unclear, i've been up all night. I am looking to make my asteroid move on a random path across the screen, then pick another path randomly and move on that path, and this should happen every time x>1024 and y>768</p>
  
  <pre><code>import flash.events.Event;
  addEventListener(Event.ENTER_FRAME, massGain);
  stop();
  
  var math1:Number = Math.floor(Math.random()*20-10);
  trace(math1);
  
  function massGain(e:Event)
  {
  
  
  Mouse.hide();
  
  Cosmo.x = mouseX;
  Cosmo.y = mouseY;
  
  Asteroid5.x = Asteroid5.x + math1;
  Asteroid5.y = Asteroid5.y + math1;
  if(Asteroid5.x &gt;1024){
  Asteroid5.x = 0;
  }
  if(Asteroid5.y &gt; 768){
  Asteroid5.y = 0;
  }
  
  
  
  }
  </code></pre>