title: Stop an Action Script at end of scene in Flash (AS3)
body: <p>I am new to action script and i am having a few problems.</p>
  
  <p>I have created a movie in Flash CC with 8 scenes.  Scene 6 has an action script that randomly places birds which fly across the screen.  Scene 7 has an almost identical script which does the same thing only slower (using a different symbol) and with a couple of variables changed.</p>
  
  <p>The first problem surfaced when testing the movie with the action script only placed in scene 6, it simply did not end at the end of scene 6 and proceeded to play through scene 7 and scene 8.</p>
  
  <p>When adding the script to scene 7, it breaks completely.  Testing the individual scenes work fine but when testing the whole movie nothing happens and I get errors.</p>
  
  <p>Here is the action script I am using:</p>
  
  <p><strong>Scene 6</strong></p>
  
  <pre><code>import flash.utils.Timer;
  
  var timer: Timer = new Timer(100, 45);
  timer.addEventListener(TimerEvent.TIMER, timerF);
  timer.start();
  
  function timerF(event: TimerEvent): void {
      var mcClip: Bird = new Bird();
      var yVal:Number = (Math.ceil(Math.random()*200));
      mcClip.x = -20;
      mcClip.y = yVal;
      addChildAt(mcClip,10);
  }
  </code></pre>
  
  <p><strong>Scene 7</strong></p>
  
  <pre><code>import flash.utils.Timer;
  
  var timer: Timer = new Timer(100, 40);
  timer.addEventListener(TimerEvent.TIMER, timerF);
  timer.start();
  
  function timerF(event: TimerEvent): void {
      var mcClip: Bird2 = new Bird2();
      var yVal:Number = (Math.ceil(Math.random()*400));
      mcClip.x = 0;
      mcClip.y = yVal;
      addChildAt(mcClip,3);
  }   
  </code></pre>
  
  <p>These are the errors I get:</p>
  
  <pre><code>Scene 7 (Birds), Layer 'Bird Action Script', Frame 1114, Line 3, Column 5
  1151: A conflict exists with definition timer in namespace internal.
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Scene 7 (Birds), Layer 'Bird Action Script', Frame 1114, Line 7, Column 10
  1021: Duplicate function definition.
  </code></pre>
  
  <p>I need to stop the script at the end of each scene, but I don't know how.  I have searched Google and cannot find anything helpful.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Many Thanks</p>