# Movieclip needs to loop but only on prompt

**URL:** https://forum.kirupa.com/t/movieclip-needs-to-loop-but-only-on-prompt/5113
**Category:** Uncategorized
**Created:** [September 1, 2002, 5:37pm UTC](https://forum.kirupa.com/t/movieclip-needs-to-loop-but-only-on-prompt/5113 "2002-09-01T17:37:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![linque](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/linque/32/50_2.png) [@linque](https://forum.kirupa.com/u/linque)
#### Post date: [September 1, 2002, 5:37pm UTC](https://forum.kirupa.com/t/movieclip-needs-to-loop-but-only-on-prompt/5113/1 "2002-09-01T17:37:46Z")

</div>

I have an .fla with multiple movieclips. For most of these, as one finishes, it calls the next with code like

```
_parent.nextmovieclip_mc.play();

```

on that next movieclip (the one to be played), the first frame is blank with actionscript stop(); so that it won’t begin at the start of the movie.

nearly every movieclip plays just once and this has worked fine.

I have run into a snag because I want _one_ of these to loop 20 times, and I’m trying to do a loop, but either it plays once and stops or never plays.

this clip should not begin at the outset of the movie, and so like the others above, it has a blank keyframe with a stop(); for frame 1

the loop I was using has in the actions layer in the second frame  
i++

and in the last frame of the action layer of the movieclip I had

if (i ==20) {  
stop();  
}

something is wrong.

I’ve tried the code on a clip that has no first frame stop, and then the code works. But I can’t have this clip playing as the movie begins.

Please help, and PLEASE, since I’m new, tell me whether to put your answer in the main timeline or in the movieclip.

---

<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 1, 2002, 7:26pm UTC](https://forum.kirupa.com/t/movieclip-needs-to-loop-but-only-on-prompt/5113/2 "2002-09-01T19:26:24Z")

</div>

If it loops, means it goes back to FIRST frame where your stop is; you might have understood the problem from your test.  
So the solution is really very simple:  
in the last frame:

if (i \<20) {  
gotoAndPlay(2); //2nd frame, so no stop here!  
}else{  
stop();  
}

---

<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 1, 2002, 7:43pm UTC](https://forum.kirupa.com/t/movieclip-needs-to-loop-but-only-on-prompt/5113/3 "2002-09-01T19:43:14Z")

</div>

wouldnt you need to put:  
i= ++i and not just ++i ??? :-\ just wondering.

Peace

---

<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 1, 2002, 7:46pm UTC](https://forum.kirupa.com/t/movieclip-needs-to-loop-but-only-on-prompt/5113/4 "2002-09-01T19:46:42Z")

</div>

doh!!!

oh my… thanks for making me see straight! :-\

fixed it in 2 seconds with your help…
