打印位图而不打印精灵?

发布于 2024-09-05 13:21:01 字数 974 浏览 2 评论 0原文

跟进: As3 打印问题,打印或取消后空白 swf

我试图想出一个在不创建精灵的情况下打印的函数,因为这似乎是导致我的问题的原因:

public function printScreen():void {


        var pJob:PrintJob = new PrintJob();

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

        var bitmapData:BitmapData = new BitmapData(root.width, root.height); 
        bitmapData.draw(root); 

        var printThis:Bitmap = new Bitmap(bitmapData);


        try {

        pJob.start();


        pJob.addPage(printThis, null, options);
        pJob.send();

        }

        catch(e:Error)
        {


        trace("Error Printing")

        }
    }

这提出了一个:

Error: Description  Implicit coercion of a value of type flash.display:Bitmap to an      unrelated type flash.display:Sprite.   

那么如何在不创建精灵的情况下打印位图?

Following up from: As3 printing problem, blanks swf after print or cancel

I am trying to comeup with a function to print without creating a sprite, because that's what it seems to be causing my problem:

public function printScreen():void {


        var pJob:PrintJob = new PrintJob();

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

        var bitmapData:BitmapData = new BitmapData(root.width, root.height); 
        bitmapData.draw(root); 

        var printThis:Bitmap = new Bitmap(bitmapData);


        try {

        pJob.start();


        pJob.addPage(printThis, null, options);
        pJob.send();

        }

        catch(e:Error)
        {


        trace("Error Printing")

        }
    }

This is coming up with an:

Error: Description  Implicit coercion of a value of type flash.display:Bitmap to an      unrelated type flash.display:Sprite.   

So how do you print a bitmap without creating a Sprite?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萝莉病 2024-09-12 13:21:01

我从未尝试过打印......但这可能会有所帮助:
pJob.addPage 需要一个精灵..因此请为其提供一个像这样包装位图的精灵:

var s:Sprite = new Sprite();
s.addChild(printThis);
pJob.addPage(s, null, options);
pJob.send();

我希望它能工作

I never tried printing... but this could help:
pJob.addPage is expecting a sprite.. so provide it with one that's wraping your bitmap like this:

var s:Sprite = new Sprite();
s.addChild(printThis);
pJob.addPage(s, null, options);
pJob.send();

I hope it works

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文