# How can I stop this code from looping

**URL:** <https://forum.kirupa.com/t/how-can-i-stop-this-code-from-looping/303359>\
**Category:** flash\
**Created:** [January 19, 2010, 12:07pm UTC](https://forum.kirupa.com/t/how-can-i-stop-this-code-from-looping/303359 "2010-01-19T12:07:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![costelloe16](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@costelloe16](https://forum.kirupa.com/u/costelloe16)\
**Post date:** [January 19, 2010, 12:07pm UTC](https://forum.kirupa.com/t/how-can-i-stop-this-code-from-looping/303359/1 "2010-01-19T12:07:38Z")

</div>

I’ve got some code working in a flash banner but google needs it to stop looping and I can’t work out how to make it loop for 3 times! I would have thought that the for (var i=0;i\<numOfItems;i++) would make it stop when it reached three loops. The code is:

var numOfItems:Number = 3;  
var radiusX:Number = 150;  
var radiusY:Number = 50;  
var centerX:Number = Stage.width/2;  
var centerY:Number = Stage.height/2;  
var speed:Number = 0.03;

for (var i=0;i\<numOfItems;i++)  
{  
var t = this.attachMovie(“item”,“item”+i,i+1);  
t.angle = i \* ((Math.PI\*2)/numOfItems);  
t.onEnterFrame = mover;

}

function mover()  
{  
this.\_x = Math.cos(this.angle) \* radiusX + centerX;  
this.\_y = Math.sin(this.angle) \* radiusY + centerY;  
var s:Number = this.\_y / (centerY+radiusY);  
this.\_xscale = this.\_yscale = s \* 100;  
this.angle += this.\_parent.speed;  
this.swapDepths(Math.round(this.\_xscale) + 100);  
}

I’d either like it to stop after a certain amount of loops, or after 12 seconds, or on a specific frame whatever is easiest!
