As3 printing problem, blanks swf after print or cancel
- by Carlos Barbosa
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.