My need is to load 4 images at one time, and I’d like to have the code in a function that could load them one after another. But all I am getting is the last one of the loop iteration - I know it due to needing an onComplete, but I can’t figure out how to make it all work passing it back and forth).
My best guess is below. If you could , please advise on how best to do this. After coding all day I am dazed and confused :)
function loadThumbnails()
{
for (var i:int = 1; i < 4; i++)
{
imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function onCompleteStatus(e:Event) { displayImage(e, new Array("1"))});
var urlRequest:URLRequest = new URLRequest(xmlData[showNumber]["s" + i + "_thumb"]);
imgLoader.load(urlRequest);
}
}
function onProgressStatus(e:ProgressEvent)
{
// this is where progress will be monitored
trace("...PROGRESS STATUS...");
}
function displayImage(e:Event, arg:Array)
{
Object(this)["tmbBox" + arg[0] + "_mc"]["tmbHolder" + arg[0] + "_mc"].addChild(imgLoader);
}