# Looping a SWF limited times

**URL:** https://forum.kirupa.com/t/looping-a-swf-limited-times/837
**Category:** flash
**Created:** [July 31, 2002, 5:25pm UTC](https://forum.kirupa.com/t/looping-a-swf-limited-times/837 "2002-07-31T17:25:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sixfish](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sixfish](https://forum.kirupa.com/u/sixfish)
#### Post date: [July 31, 2002, 5:25pm UTC](https://forum.kirupa.com/t/looping-a-swf-limited-times/837/1 "2002-07-31T17:25:45Z")

</div>

I need to loop my SWF 3 times and have it freeze on the last frame of the movie. I assume a conditional “if” “else” action is needed but cannot get it too work. Any help???

Thanks,  
sixfish

---

<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: [July 31, 2002, 9:06pm UTC](https://forum.kirupa.com/t/looping-a-swf-limited-times/837/2 "2002-07-31T21:06:31Z")

</div>

Try this:

firstFrame of your FLA

counter=1

lastFrame of you FLA

if (counter==3) {  
stop();  
} else {  
counter++;  
gotoAndPlay(2);  
}

---

<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: [July 31, 2002, 10:08pm UTC](https://forum.kirupa.com/t/looping-a-swf-limited-times/837/3 "2002-07-31T22:08:18Z")

</div>

i added this code to the last frame only:

counter = counter+1;  
if (counter\<3) {  
\_root.mcalbums.gotoAndPlay(1);  
} else {  
\_root.mcalbums.gotoAndStop(“final”);  
}

“mcalbums” was my movie clip. I couldn’t believe how simple it was. I was looking at books, trying “do while” and “for” statements, complicating things.

Usually the simplist solution is the right answer!

Thanks again.
