Hi,
So I 'm checking to see if an image file exist but I don’t think the code checks but the last iteration in the loop. Here’s my code:
var i = 1;
var j;
var loader:URLLoader = new URLLoader();
var myArr:Array = new Array();
loader.addEventListener(IOErrorEvent.IO_ERROR, imgLoadErrorMethod);
var request:URLRequest = new URLRequest(“images/birds” + i + “.jpg”);
for (i = 1; i <= 8; i++)
{
request = new URLRequest(“images/birds” + i + “.jpg”);
loader.load(request);
trace ("i: " + i)
}
function imgLoadErrorMethod(event:IOErrorEvent):void {
trace("ioErrorHandler: ");
j = i - 1 ;
trace(“images/birds” + j + “.jpg. Does not exist”)
}
THIS IS WHAT IT OUTPUTS:
i: 1
i: 2
i: 3
i: 4
i: 5
i: 6
i: 7
i: 8
ioErrorHandler:
images/birds8.jpg. Does not exist
I only have 7 images. If I change the 8 in the for loop to 9
THIS IS WHAT IT OUTPUTS:
i: 1
i: 2
i: 3
i: 4
i: 5
i: 6
i: 7
i: 8
i: 9
ioErrorHandler:
images/birds9.jpg. Does not exist
I was expecting a both
ioErrorHandler:
images/birds8.jpg. Does not exist
ioErrorHandler:
images/birds9.jpg. Does not exist
Can someone help me fix this or if you know a better way to check if an image file exist could you let me know.