Adobe air app quits when I try to print function after show invoice function?

I am trying to create an aerial application using flash profession cc. I have a function called invoice count and bill printing in it. When I print directly without showing that the paper salon application application is working correctly. But when I try to use the invoice function and then try to print the invoice, it displays the print dialog and when I give the print command, the "Adobe Air Application Stop" appears. Here is the invoice function code

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();
    }

      

Here is the code for the printed invoice

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);
    }

      

Each function works correctly, but I could not resolve the conflict between printing and displaying invoices. Please guys need advice and help. Thank.

+3


source to share


1 answer


Sometimes, buffering display objects with text and shapes can crash your application. While I cannot comment on why, I can share what I have done in the past to get around this issue.

Printing the page as a bitmap can sometimes fix this problem. In your case, it will look like this:

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

printJob.addPage(billing,null,printOptions);

      



OR for a shorter built-in way:

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

      

Note that sometimes this makes the text not as crisp as FlashPlayer basically draws the object to pixel data before sending it to the spooler.

+1


source







All Articles