PrintJob won't wait for component to load image

Hello all, I’ll start out by saying that I don’t have much experience in AS3 as compared to AS2 but I’m slowly but surely making my transition. Right now I’m having a quirky problem that I was wondering if someone could help me with. Here’s the setup :

I have a movie clip called base, which houses a bunch of uiloader components, that load images. There are several ‘pages’ which are populated by changing the source property of the components when you click next/prev page. I’ve added an option to print these pages, and everything goes fine when printing a single page. However, when I want to print all of them, the print goes through before the images fully load. I seem to have trouble getting the printjob to addPage ONLY when the uiloaders finish loading.

the current script :


for(var a=curpage;a<maxpage;a++) // loops through 'pages'
{
    flipPage(); // populates current page with images
    printJob.addPage(base,null,printOptions);
}

I’ve tried doing something like this :


for(var a=curpage;a<maxpage;a++) // loops through 'pages'
{
    flipPage(); // populates current page with images
    while(labels[6][1].imgLoader.percentLoaded==100) //The last instance to load anything
    {    
        printJob.addPage(base,null,printOptions);
    }
}

But it seems to just skip over it. I’ve checked the value of percentLoaded and it **does **eventually reach 100 - it just seems that the timing is a bit funny and the pages never add.


...
labels[6][1].bcode.addEventListener(Event.COMPLETE,addprintpage);
...


function addprintpage(e)
{
     printJob.addPage(base,null,printOptions);
}



Doesn’t work either. The print dialog comes up, but nothing prints afterwards (I’m assuming because no pages were successfully added)

Any suggestions?