# For loop question

**URL:** <https://forum.kirupa.com/t/for-loop-question/62810>\
**Category:** flash\
**Created:** [August 31, 2004, 2:57pm UTC](https://forum.kirupa.com/t/for-loop-question/62810 "2004-08-31T14:57:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Locnoi](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/locnoi/32/714_2.png) [@Locnoi](https://forum.kirupa.com/u/Locnoi)\
**Post date:** [August 31, 2004, 2:57pm UTC](https://forum.kirupa.com/t/for-loop-question/62810/1 "2004-08-31T14:57:01Z")

</div>

Hello,

I have a question for using the for loop

I have this code running and it’s doing perfectly fine

for (i = 0; i \<= 20; i ++){  
newMovieName = “movie” + i;  
this[newMovieName].gotoAndPlay(“start”);  
}

what if I want all 21 movies to play except for lets us movie number 7? Is there a way to ask the for loop to skip 7? Thanks!!!

Loc

---

<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:** [September 8, 2004, 3:29pm UTC](https://forum.kirupa.com/t/for-loop-question/62810/2 "2004-09-08T15:29:21Z")

</div>

The “for” statement doesn’t actually have a function for emitting values. You could miss out the number seven by using an additional “if” statement to check it 7 is the current number in the for loop or not. Try using this code…

```auto
for (i = 0; i <= 20; i ++){
if (i != 7) {
newMovieName = "movie" + i;
this[newMovieName].gotoAndPlay("start");
}
}

```

See how it works? **If** “i” is **not equal** to seven then it executes your code, otherwise it does nothing and moves onto the next loop (where i equals 8).

Hope this helps,  
Dave

---

<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:** [September 8, 2004, 3:49pm UTC](https://forum.kirupa.com/t/for-loop-question/62810/3 "2004-09-08T15:49:38Z")

</div>

Except in this case you want to set if i != 6 since your loop starts at 0 and you want to not play movie #7. 😉
