As3 printing problem, blanks swf after print or cancel

Posted by Carlos Barbosa on Stack Overflow See other posts from Stack Overflow or by Carlos Barbosa
Published on 2010-06-11T09:08:59Z Indexed on 2010/06/11 9:12 UTC
Read the original article Hit count: 268

Hey all!

ok back at another issues in as3 printing

Code: //Function to print entire screen function printFunction(event:MouseEvent):void { var myPrintJob:PrintJob = new PrintJob(); var oldScaleX:Number = root.scaleX; var oldScaleY:Number = root.scaleY;

//Start the print job
myPrintJob.start();

//Figure out the new scale
var newScaleX:Number = myPrintJob.paperWidth/root.width;
var newScaleY:Number = myPrintJob.paperHeight/root.height;

//Shrink in both the X and Y directions by the same amount (keep the same ratio)
if(newScaleX < newScaleY)
    newScaleY = newScaleX;
else
    newScaleX = newScaleY;

root.scaleX = newScaleX;
root.scaleY = newScaleY;

//Print the page
myPrintJob.addPage(Sprite(root));
myPrintJob.send();

//Reset the scale to the old values
root.scaleX = oldScaleX;
root.scaleY = oldScaleY;

} I cant seem to find anything thats really helpful with this. When i click cancel on the print dialog box, i get error below and it blanks out my swf.

© Stack Overflow or respective owner

Related posts about flex

Related posts about flash