AS3打印问题,空白打印后SWF或取消 [英] As3 printing problem, blanks swf after print or cancel
问题描述
确定回在AS3印刷的另一个问题
ok back at another issues in as3 printing
//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;
}
我似乎发现了什么那这个真的很有帮助。当我点击取消在打印对话框中,我得到下面的错误,并清空了我的SWF。
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.
错误包括,每当我试图打印并取消它,甚至当我这样做成功地打印,SWF一片空白。
The error consists, that whenever i try to print and cancel it, or even when i do succesfully print, swf goes blank.
推荐答案
有两种打印类型,矢量和位图。因为你只是路过的根,它会尝试打印的一切作为载体。但你可能会看到的是,在某些版本的Flash播放器在某些操作系统矢量打印不起作用。我通常创建要DisplayObject的位图快照和打印本。
There are two printing types, vector and bitmap. Because you are just passing in the root it will try to print everything as a vector. But what you might be seeing is that in some versions of the Flash player on some operating systems vector printing doesn't work. I normally create a bitmap snapshot of the displayobject that you want and print this.
VAR的位图数据:的BitmapData =新的BitmapData(root.width,root.height);
的BitmapData.draw(根);
VAR printThis:位图=新位图(位图数据);
var bitmapData:BitmapData = new BitmapData(root.width, root.height);
bitmapData.draw(root);
var printThis:Bitmap = new Bitmap(bitmapData);
请确保你把它添加到舞台上打印,以便在此之前,preVIEW作品和心灵的最大的位图数据的大小。当您完成删除该位图。
Make sure you add it to the stage before you print so that preview works and mind the max bitmap data size. When you are finished delete the bitmap.
这篇关于AS3打印问题,空白打印后SWF或取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!