JPEG File verification using loadVar

I’m building an array of JPEG files from an XML file. I need a way to verify that the file exists on the server as it build the array. If it’s not there I want to substitute another file name in it’s place: default.jpg.

Using loadVars I came up with this code… which won’t work:

//Loop parse XML for recently played songs and verify file on server
var img_array = new Array();//JPEG file names
var desc_array = new Array();//Text descriptions of JPEG files
for (var i=13; i < 23; i++) {//Checks only between nodes specified
var t_name = doc.firstChild.childNodes*.attributes.name;//Get image file name from XML
//Check to see if JPEG file exists on server
fileExists = new LoadVars();
fileExists.load(pRadio + “/thumbs/” + t_name);//URL path to actual file
fileExists.onLoad = function (success) {
if (success) {
img_array.push(t_name);//On success adds file name to img_array Verified
} else {
t_name=“default.jpg”;//On failure substitute default.jpg file name and push to array
img_array.push(t_name);
}
}
//Parse description text and push to array
var t_desc = doc.firstChild.childNodes*.firstChild.nodeValue;
if (t_desc== undefined) t_desc = “”;
desc_array.push(t_desc);
}

I posted this on the FLASH forum but the only answer I got was that it can’t be done and I should use a server-side script. Flash should be able to tell if a load failed or not…yes. Any suggestions would be greatly appreciated.

hillcreative