# Loop or Var

**URL:** <https://forum.kirupa.com/t/loop-or-var/12206>\
**Category:** flash\
**Created:** [January 28, 2003, 12:15pm UTC](https://forum.kirupa.com/t/loop-or-var/12206 "2003-01-28T12:15:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![soulty](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/soulty/32/105_2.png) [@soulty](https://forum.kirupa.com/u/soulty)\
**Post date:** [January 28, 2003, 12:15pm UTC](https://forum.kirupa.com/t/loop-or-var/12206/1 "2003-01-28T12:15:41Z")

</div>

Hey, If i wanted to loop a section of my timeline and then after a certain amount of times of the loop (say 5) go to another section, what would be the best way to achieve this, using a few variables or a loop statement.

I ve been trying variables, because my guess is that i need to have a counter, for the times loop, problem is Iam no good at variables. any help will be great.

what i got is,

```php

totalcount = totalsum;
totalsum = 0;

```

and on the last frame

```php

totalsum = +1;
if (totalcount=5) {
    gotoAndPlay(185);
} else {
    gotoAndPlay(240);
}

```

pretty bad aye.  
(-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 28, 2003, 12:29pm UTC](https://forum.kirupa.com/t/loop-or-var/12206/2 "2003-01-28T12:29:26Z")

</div>

i worked it out!!!

first

```php

totalsum = 0;

```

last

```php

totalsum = totalsum+1;
if (totalsum==5) {
    gotoAndPlay(185);
} else {
    gotoAndPlay(240);
}

```

i guess i am not too bad after all :beam:
