As3 打印问题,打印或取消后出现空白 swf [英] As3 printing problem, blanks swf after print or cancel

查看:26
本文介绍了As3 打印问题,打印或取消后出现空白 swf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

回到 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 播放器版本中,矢量打印不起作用.我通常会创建您想要的显示对象的位图快照并打印出来.

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 = new BitmapData(root.width, root.height);bitmapData.draw(root);var printThis:Bitmap = new Bitmap(bitmapData);

确保在打印之前将其添加到舞台,以便预览工作并注意最大位图数据大小.完成后删除位图.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆