I have the following code:
The first if statement creates a url string and passes it to the IOErrorEventHandler() function.
This function attempts to load the url and I have listeners on it for error and HTTP status. If I get an http status 404, I want to assign validJpgInfos="false". (could use the IOErrorHandler instead, but would prefer to base it on status code).
Anyway, the problem I am having, is the when the first if statement evaluates to true, it runs the handler, then returns back to the next if statement above and finishes the rest of the function, then it executes the ioErrorHandler and httpStatusHandler functions.
How do I get it to immediately run the handler function(s) "before" returning back to the original calling function? Basically, the second if statement is dependent upon the result of the httpStatus, so I need a way to pass that back to it.
Sure it's got to be simple, but sure isn't coming to me today..
thanks for any ideas,
R_
Code:
for each (var fieldInfo:PopUpFieldInfo in popUpInfo.popUpFieldInfos)
{
if (fieldInfo.visible && fieldInfo.fieldName == "ID")
{
var imgx:String = "http://localhost/fv30/photos/" + formattedAttributes[fieldInfo.fieldName] + ".JPG";
IOErrorEventHandler(imgx);
}
if (validJpgInfos == "false"){
validMediaInfos = null;
}
Do the rest of function
from here down....
}
private function IOErrorEventHandler(imgx:String):void {
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
var request:URLRequest = new URLRequest(imgx);
loader.load(request);
}
private function ioErrorHandler(event:IOErrorEvent):void {
validJpgInfos = "false";
}
private function httpStatusHandler(event:HTTPStatusEvent):void {
if (event.status == 404){
validJpgInfos = "false";}
}
This function attempts to load the url and I have listeners on it for error and HTTP status. If I get an http status 404, I want to assign validJpgInfos="false". (could use the IOErrorHandler instead, but would prefer to base it on status code).
Anyway, the problem I am having, is the when the first if statement evaluates to true, it runs the handler, then returns back to the next if statement above and finishes the rest of the function, then it executes the ioErrorHandler and httpStatusHandler functions.
How do I get it to immediately run the handler function(s) "before" returning back to the original calling function? Basically, the second if statement is dependent upon the result of the httpStatus, so I need a way to pass that back to it.
Sure it's got to be simple, but sure isn't coming to me today..
thanks for any ideas,
R_