Printing multiple pages of a scrollable dynamic text box

I’ve seen a number of posts in this forum and others about how to print text out of a scrollable dynamic text box. Some people have come up with solutions like making another dynamic text box off-stage that is A4-size that contains the same text as the scrollable text box. The printJob() action then uses this text box as its target and prints a nice A4 page.

But what if there is so much text, it needs more than one A4 page to print? I’ve been searching for answers without much luck, but I did come across this:

on (click) {
//create PrintJob object
myPrintJob = new PrintJob();
//display print dialog box
var maxS:Number; //total number of lines in textArea
var botS:Number; //total number of lines visible in scroll box
//loop through untill i have added a page for each scroll pane
for (var i = 1; botS*i<=maxS; i++) {
// add specified area to print job
myPrintJob.addPage("_root.print_txta", {xMin:-36, xMax:612, yMin:-36, yMax:792}, {printAsBitmap:false});
maxS = _root.print_txta.label.maxscroll ;
botS = _root.print_txta.label.bottomScroll;
//manually scroll the box
_root.print_txta.vPosition = botS; 
// send pages from the spooler to the printer
// clean up
delete myPrintJob;


This would obviously be attached to a button, and is trying to print a text box named “print_txta” at the _root level. The trouble is, it doesn’t work!.

I’ve tried changing it around a bit, like relocating the ending } of the loop, but still cannot get it to work. All it does is print the one page over and over (luckily I was printint to Adobe PDF, so I wasn’t wasting paper! I recommend you do the same if you want to test the script!) and if you have more text than will fit on one A4 page, it ignores everything past the first page!

I wonder if anyone else on this board can make more sense out of the above script and perhaps get it to actually work in the way it was supposed to? I think this would benefit a lot of people out there.