Trying to load a directory of hundreds of images into separate movie clips using the AS3 Loader class. By assigning an Event.COMPLETE listener to the Loader, the callback function only has a reference to the Loader and not to the image that’s being loaded or the parent that it’s being loaded into. So if I need to Tween on this image after the load is completed, no dice. Instead, assign an Event.ENTER_FRAME to the parent MovieClip and dig a byte comparison out of the contentLoaderInfo object…
for each ( var imgPath in imgXML.elements () ) {
var imgLoader:Loader = new Loader ();
imgClip.addChild ( imgLoader );
imgClip.addEventListener ( Event.ENTER_FRAME, imgLoading );
imgLoader.load ( new URLRequest ( imgPath ) );
}
…
function imgLoading ( e:Event ):void {
var bL:Number = e.target.getChildAt ( 0 ).contentLoaderInfo.bytesLoaded;
var bT:Number = e.target.getChildAt ( 0 ).contentLoaderInfo.bytesTotal;
if ( bT == bL ) {
e.target.removeEventListener ( Event.ENTER_FRAME, imgLoading );
e.target.parent.Tweener // etc.
}
}