title: Action Script 3 .Loop the animation 3 times and stop
body: <p>I working on Flash banners and I would like the animation to loop 3 times and then stop. I don't know Action Script but I found this code:</p>
  
  <p>On the 1st frame I used this:</p>
  
  <pre><code>_root.loops_played = 0;
  
  if (_root.loops_played &gt;= 3){
  
  stop(); //*
  
  } else {
  
  play();
  
  }
  </code></pre>
  
  <p>On the last frame:</p>
  
  <pre><code>_root.loops_played += 1;
  </code></pre>
  
  <p>Unfortunately the animation keeps looping and I get this error:</p>
  
  <pre><code>Scene 1, Layer 'actions', Frame 1, Line 1   1120: Access of undefined property _root.
  Scene 1, Layer 'actions', Frame 1, Line 3   1120: Access of undefined property _root.
  Scene 1, Layer 'actions', Frame 175, Line 1 1120: Access of undefined property _root.
  Scene 1, Layer 'actions', Frame 175, Line 1 1120: Access of undefined property _root.
  </code></pre>
  
  <p>Could anyone help please?</p>