当我尝试在名为 "show bill" 的函数后打印时,Adobe air 应用程序退出?

Adobe air application quits when i try to print after a function called "show bill"?

我正在尝试使用 flash professional cc 创建一个 air 应用程序。我在其中具有称为显示账单和打印账单的功能。当我直接打印而不显示账单时,adobe air 应用程序可以正常工作。但是当我尝试使用显示账单功能然后尝试打印账单时,它会显示打印对话框,当我给出打印命令时 an"Adobe Air Application Stop working window shows up" 。这是显示账单功能的代码

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 之间的冲突..请大家提供建议和帮助..谢谢

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

将页面打印为位图有时可以解决这个崩溃问题。在你的情况下是这样的:

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

printJob.addPage(billing,null,printOptions);

或更短的内联方式:

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

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