# Terminate a loop once a file is not found

**URL:** <https://forum.kirupa.com/t/terminate-a-loop-once-a-file-is-not-found/306472>\
**Category:** Uncategorized\
**Created:** [March 16, 2010, 7:49am UTC](https://forum.kirupa.com/t/terminate-a-loop-once-a-file-is-not-found/306472 "2010-03-16T07:49:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Whitnemp](https://avatars.discourse-cdn.com/v4/letter/w/5fc32e/32.png) [@Whitnemp](https://forum.kirupa.com/u/Whitnemp)\
**Post date:** [March 16, 2010, 7:49am UTC](https://forum.kirupa.com/t/terminate-a-loop-once-a-file-is-not-found/306472/1 "2010-03-16T07:49:52Z")

</div>

I have a loop that is running to display images of all my clients.

So, the image names are client0.png, client1.png,client2.png and so forth.

I have a movie clip that is duplicated and uses the Loadmovie command to call the images. The code I’m using looks like this.

var position = 0;  
for (i=0; i\<50; i++) {  
emptyMC.duplicateMovieClip(“emptyMC”+i, i, {\_y:+position});  
var position = position +150  
loadMovie (“[http://www.url.com/client"+i+".png](http://www.url.com/client%22+i+%22.png)”, “emptyMC”+i);

It’s working great! But I don’t have 50 clients, so I was wondering if there was a way to terminate this loop once it was unable to find a file. Does it already terminate once the file isn’t found? Every time I test, the output unfortunately tells me “file cannot be found blah blah blah” or whatever. And all I want to do in order to update this page is to upload another image to the server without going back into the .swf and changing the i\<50 to the exact number of clients I have. Perhaps I’m going about this the wrong way? Hopefully you guys can help. Thanks!
