Adobe Air应用程序在我尝试打印一个名为"显示账单"的功能后退出

时间:2015-05-28 15:27:32

标签: actionscript-3 flash printing air desktop

我正在尝试使用flash专业cc创建一个空气应用程序。我有一个叫做show bill和print bill的功能。当我直接打印显示该法案adobe空气应用程序正常工作。但是,当我尝试使用show bill功能,然后尝试打印它显示打印对话框时,当我给出一个打印命令时,Adobe Air Application Stop工作窗口显示" 。这是show bill功能的代码

public function ShowBill(e: MouseEvent): void {
        total();
        Merge();
        bswap();
        billing.x = 450;
        billing.y = 100;
        billing.height = 300 ;
        billing.width = 500 ;
        addChild(billing);
        billing.close_btn1.addEventListener(MouseEvent.CLICK, rmvBilling);
        billing.close_btn1.visible = true;
        if(billing._item.item1.text != "")
        {
            billing._item.visible = true;
            billing._item.close_btn1.visible = true;
        }
        if(item2.item1.text != "")
        {
        item2.close_btn1.visible = true;
        }
        if(item3.item1.text != "")
        {
        item3.close_btn1.visible = true;
        }
        if(item4.item1.text != "")
        {
        item4.close_btn1.visible = true;
        }
        if(item5.item1.text != "")
        {
        item5.close_btn1.visible = true;
        }
        if(item6.item1.text != "")
        {
        item6.close_btn1.visible = true;
        }
        if(item7.item1.text != "")
        {
        item7.close_btn1.visible = true;
        }
        if(item8.item1.text != "")
        {
        item8.close_btn1.visible = true;
        }
        if(item9.item1.text != "")
        {
        item9.close_btn1.visible = true;
        }
        if(item10.item1.text != "")
        {
        item10.close_btn1.visible = true;
        }

        total();
    }

以下是打印帐单的代码

public function printContent(e: MouseEvent) {
        update1();
        billing.close_btn1.visible = false;
        billing._item.close_btn1.visible = false;
        item2.close_btn1.visible = false;
        item3.close_btn1.visible = false;
        item4.close_btn1.visible = false;
        item5.close_btn1.visible = false;
        item6.close_btn1.visible = false;
        item7.close_btn1.visible = false;
        item8.close_btn1.visible = false;
        item9.close_btn1.visible = false;
        item10.close_btn1.visible = false;

        var printJob: PrintJob = new PrintJob();
        if (printJob.start()) {
                if (billing.width < printJob.pageWidth) {
                    billing.width = printJob.pageWidth;
                    billing.scaleY = billing.scaleX;
                }
                printJob.addPage(billing);
                printJob.send();
                clear();
            }

    }
    public function update1():void{
        var phpVars:URLVariables = new URLVariables();
        var phpFileRequest:URLRequest = new URLRequest("http://localhost/icyspicy/update.php");
        phpFileRequest.method = URLRequestMethod.POST;
        phpFileRequest.data = phpVars;
        var phpLoader:URLLoader = new URLLoader();
        phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
        phpVars.systemCall="update";
        phpVars.table = String(tabNbill1.getDubTblNo.text);
        phpVars.date = String(billing.the_date.text);
        phpVars.items = String(billing._item.item1.text+","+item2.item1.text+","+item3.item1.text+","+item4.item1.text+","+item5.item1.text+","+item6.item1.text+","+item7.item1.text+","+item8.item1.text+","+item9.item1.text+","+item10.item1.text );
        phpVars.quantity = String(billing._item.q2.text+","+item2.q2.text+","+item3.q2.text+","+item4.q2.text+","+item5.q2.text+","+item6.q2.text+","+item7.q2.text+","+item8.q2.text+","+item9.q2.text+","+item10.q2.text);
        phpVars.total =String( billing.total.text);
        phpLoader.load(phpFileRequest);
        postData(mypath, getResponse);
    }

每个功能都正常工作但是printbill和show bill之间的冲突我无法解决..请各位家伙需要建议和帮助..谢谢你

1 个答案:

答案 0 :(得分:1)

有时使用文本和形状对显示对象进行假脱机可能会使应用程序崩溃。虽然我无法评论原因,但我可以分享我过去所做的工作来解决这个问题。

将页面打印为位图有时可以解决此崩溃问题。在你想要的情况下:

var printOptions:PrintJobOptions = new PrintJobOptions();
printOptions.printAsBitmap = true;

printJob.addPage(billing,null,printOptions);

OR用于更短的内联方式:

printJob.addPage(billing, null, new PrintJobOptions(true));

请注意,有时这样做会使文字看起来不那么清晰,因为FlashPlayer基本上是在将对象发送到假脱机程序之前将其绘制为像素数据。