I recently developed a help resource application that builds the interface and loads all the main and sub navigation items, pages contents, and related resources dynamically. This was to make it easy to provide search and print functionality, as well as interface scalability. Therefore my print feature creates a print layout MovieClip (so as to format well for 8.5 x 11 and printer margins) and loads the appropriate text content related to the visible page on screen when the print button is pressed.
I thought the print was all set to go, but what I found out is that once you print a page of the Help Resource application that same page prints in place of any other page you print from there on out.
My print button calls a function that pulls all the appropriate dynamic data (page title, page contents, related resource names, etc.) and formats it as HTML and adds it to my print layout MovieClips text field (docPrint._txt).
That function then calls my printJob function which creates a blank sprite, adds my print layout movieclip to that sprite, resizes the print layout MovieClip’s text field to fit appropriately within the printer margins and prints the file.
Anyone have any ideas why my dynamic content prints as the same page each time? Note that if I trace the contents of my text field for my print layout MovieClip the contents change each time, but the print stays the same.
Sorry for the long post and huge thanks to anyone who may have an answer.
Have a great day!
// Print Button --------------------------
function printClick(event:MouseEvent):void {
docContentsLoad();
}
// ---------------------------------------
// Load Text Contents --------------------
function docContentsLoad():void {
docPrint._txt.htmlText = “<font size=‘14’>”+intTitle+"</font><br>";
docPrint._txt.htmlText += “<font size=‘16’><b>”+curTitle+"</b></font><br><br>";
docPrint._txt.htmlText += “<font size=‘11’>”+curText+"</font><br>";
docPrint._txt.htmlText += curResources;
docPrint._txt.autoSize = TextFieldAutoSize.LEFT;
printJob();
}
// ---------------------------------------
// Print Job -----------------------------
function printJob():void {
var myPrintJob:PrintJob = new PrintJob();
var printPage:Sprite = new Sprite();
printPage.addChild(docPrint);
if (myPrintJob.start()) {
try {
myPrintJob.addPage(printPage);
} catch (error:Error) {
// Print Add Page Error
}
// Print Send
myPrintJob.send();
} else {
// Print Canceled
}
myPrintJob = null;
}
// ---------------------------------------