I have some AS2 code that opens a SWF file through an HttpHandler.
I'm trying to get the program to recognize when a requested file is missing.
My first attempt involved using LoadVars and "load", and only calling loadMovie if the file successfully loaded (found the technique somewhere out here). However, I found that the ProcessRequest function in the HttpHandler was getting called twice when the file does exist. Makes sense - once for load, once for loadMovie.
Now I'm using MovieClipLoader instead (also found this technique out here). This way does call ProcessRequest only once whether or not the file is found. But my problem is that the onLoadError function is only working when I give it a bad URL. If I give it a good URL that passes a bad filename to the handler, the handler throws an error, but my onLoadError function doesn't seem to recognize that there's a problem - I just get a blank area where the error message should be showing up.
Here's the relevant AS2 code:
function CheckFileExists(inFile) {
var mclListener:Object = new Object();
mclListener.onLoadError = function(target_mc:MovieClip, err:String){
if(err=="URLNotFound")
{
target_mc.createTextField("error_txt", 1, 0, 0, 100, 20);
target_mc.error_txt.autoSize = "left";
target_mc.error_txt.text = "URL not found: \n\t" + target_mc._url;
}
else //I would expect this block to handle the error, since the URL is good.
{
target_mc.createTextField("error_txt", 1, 0, 0, 100, 20);
target_mc.error_txt.autoSize = "left";
target_mc.error_txt.text = "some other problem: \n\t" + target_mc._url;
}
}
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(mclListener);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcl.loadClip(inFile, mc);
}
Little help?