# PrintJob won't wait for component to load image

**URL:** <https://forum.kirupa.com/t/printjob-wont-wait-for-component-to-load-image/328368>\
**Category:** flash\
**Created:** [May 11, 2012, 6:44pm UTC](https://forum.kirupa.com/t/printjob-wont-wait-for-component-to-load-image/328368 "2012-05-11T18:44:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BuG56](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@BuG56](https://forum.kirupa.com/u/BuG56)\
**Post date:** [May 11, 2012, 6:44pm UTC](https://forum.kirupa.com/t/printjob-wont-wait-for-component-to-load-image/328368/1 "2012-05-11T18:44:59Z")

</div>

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 :

```auto

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 :

```auto

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.

```auto

...
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?
