# File Detection

**URL:** <https://forum.kirupa.com/t/file-detection/173381>\
**Category:** flash\
**Created:** [December 24, 2005, 6:08am UTC](https://forum.kirupa.com/t/file-detection/173381 "2005-12-24T06:08:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JProvost](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@JProvost](https://forum.kirupa.com/u/JProvost)\
**Post date:** [December 24, 2005, 6:08am UTC](https://forum.kirupa.com/t/file-detection/173381/1 "2005-12-24T06:08:12Z")

</div>

Hey all.  
I’m an illustrator trying to save myself some time updating my site with new images by having Flash automatically detect how many images are uploaded to my thumbs directory. The thumbs will be named sequentially (001.jpg, 002.jpg, 003.jpg, etc), and from there I can load them into duplicate movie clips and set up linking to the full size images… but it’s not as easy as I thought.

I’ve been working with the file detection technique found here [http://www.flashguru.co.uk/checking-if-a-file-exists/](http://www.flashguru.co.uk/checking-if-a-file-exists/) but I’m not sure it’s giving me the results I need.

If anyone can help with my source code, or suggest a different strategy, it’d be most appreciated.

My current (slightly less Flash-savvy) website can be found at [http://inertia.autophobic.net/](http://inertia.autophobic.net/)

Thanks! Code Below\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

var FileName:String="";  
FileExists=new LoadVars();  
FileExists.\_parent=this;

//makes name of next file to detect  
function MakeName(FileNum) {  
FileName = “illustration/thumbs/00”+FileNum+".jpg";  
}

FileExists.onLoad=function(success){  
//success is true if the file exists, false if it doesnt  
if(success) {  
//the file exists  
duplicateMovieClip(thumb, “thumb”+FileNum, FileNum);  
thumb.loadClip(FileName);  
} else {  
//done checking  
FileNum=0;  
}

while (FileNum\>0) {  
MakeName(FileNum);  
FileExists.load(FileName);  
FileNum++;  
}
