Tell flash to wait for an external SWF that dynamically adds images to fully load

the full title of this should be “tell flash to wait for an external SWF that dynamically adds images to fully load before proceeding with addChild’” but i ran out of space…

i have an SWF file, which loads an external SWF… and the external SWF file is an image gallery that dynamically loads images…

this is the code and it works to some degree…

function load3dPage():void
{
    if(pagesHolder.numChildren > 0)
    {
    pagesHolder.removeChildAt(0);
    }
    var request:URLRequest = new URLRequest("includes/threeD.swf");
    var loader:Loader = new Loader()
    loader.load(request);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addMediaPage);
}

function addMediaPage(loadEvent:Event):void
{
    trace("function runs");
    pagesHolder.addChild(loadEvent.currentTarget.content);
}

my problem is that the external SWF file is added even though the images in it have not yet been all loaded… i assume this is because flash calculates the file size of the “raw” external SWF without realizing that it (the external SWF) will run another script on its own to load the images… so technically, flash doesnt account for the images that will load…therefore the “COMPLETE” eventlistener only listens for the “raw” file size of the external SWF…

basically, i guess what im trying to say is, is there a way i can tell flash to “addChild” the external SWF only after it has run the script and loaded the external images as well…

in case you’re wondering, this is the code inside the external SWF that adds the images:

var thumbnail:thumbnailSelector;
var thumbXPosition:Number = 528.7;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("includes/XML files/thumbnailsXML.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadedConfirm);
var thumbsXML:XML;
var thumbsXMLList:XMLList;
var thumbLoader:Loader;

function xmlLoadedConfirm(event:Event):void
{
    thumbsXML = XML(event.target.data);
    thumbsXMLList = thumbsXML.children();
    //trace(thumbsXMLList.length());
    loadThumbnails();
}

function loadThumbnails():void
{
    for (var i:Number = 0; i < 4; i++)
    {
        thumbnail = new thumbnailSelector;
        thumbnail.x = thumbXPosition - 40;
        works_selection.addChild(thumbnail);
        thumbXPosition = thumbnail.x;
        
        thumbLoader = new Loader();
        thumbLoader.load(new URLRequest(thumbsXMLList*.attribute("source")));
        thumbnail.thumbPicHolder.addChild(thumbLoader);
    }
}