# How to loop through frames

**URL:** <https://forum.kirupa.com/t/how-to-loop-through-frames/35603>\
**Category:** flash\
**Created:** [November 15, 2003, 10:35pm UTC](https://forum.kirupa.com/t/how-to-loop-through-frames/35603 "2003-11-15T22:35:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maboroshi](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@maboroshi](https://forum.kirupa.com/u/maboroshi)\
**Post date:** [November 15, 2003, 10:35pm UTC](https://forum.kirupa.com/t/how-to-loop-through-frames/35603/1 "2003-11-15T22:35:32Z")

</div>

Hi I have a question I want to be able to loop using gotoAndPlay 3 times through a certain section of frames in my flash movie after 3 times is up I want to be able to continue on to the next frames untill the end of the movie

I guess I am not much of a programmer because I tried good and hard to get this to work

I would like to hear your thoughts on how I could accomplish this thank you

maboroshi

---

<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:** [November 15, 2003, 11:25pm UTC](https://forum.kirupa.com/t/how-to-loop-through-frames/35603/2 "2003-11-15T23:25:27Z")

</div>

It’s not the best but it will accomplish what you need,  
On the third frame place:  
[AS]  
if(\_root.counter == undefined){  
\_root.counter = 1;  
gotoAndPlay(1);  
} else if(\_root.counter \>= 3){  
delete \_root.counter;  
gotoAndPlay(4);  
} else {  
\_root.counter++;  
gotoAndPlay(1);  
}  
[/AS]

There are lots of better ways to accomplish this but that should be the easiest to understand.  
Hope that helps,  
Shawn

---

<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:** [November 16, 2003, 12:31am UTC](https://forum.kirupa.com/t/how-to-loop-through-frames/35603/3 "2003-11-16T00:31:45Z")

</div>

Hey Thanks

It works great

Cheers

Andrew

Maboroshi

---

<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:** [November 16, 2003, 12:45am UTC](https://forum.kirupa.com/t/how-to-loop-through-frames/35603/4 "2003-11-16T00:45:14Z")

</div>

You could simply use

```auto
this.counter>=3 ? this.gotoAndPlay(4) : this.gotoAndPlay(1);
this.counter++;

```

---

<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:** [November 16, 2003, 1:00am UTC](https://forum.kirupa.com/t/how-to-loop-through-frames/35603/5 "2003-11-16T01:00:42Z")

</div>

Like I said there are better ways…
