Basically I've got a code which should load a lot of images so I need a function to load them. The problem is that addEventListener requires a function which it will call when the event have been raised.
I need to find a way to either make the loadImage function return ONLY after the event was raised or make the function raised in addEventListener to return it's parent function.
function loadImage(imagePath:String)//:BitmapData
{
var internalLoader:Loader = new Loader();
var internalImageRequest = new URLRequest(imagePath);
var loadingComplete:Boolean = false;
internalLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
function (event:Event):void
{
loadingComplete = true;
}
);
internalLoader.load(internalImageRequest);
//I need to wait 'till the event have been raised and then RETURN , NOT BEFORE THAT
//var tempImg:Bitmap = Bitmap(internalLoader.content);
//return tempImg.bitmapData;
}
Thanks in advance