【问题标题】:Print a bitmap without printing a sprite?打印位图而不打印精灵?
【发布时间】:2010-06-12 07:26:11
【问题描述】:

跟进来自:As3 printing problem, blanks swf after print or cancel

我正在尝试想出一个无需创建精灵即可打印的功能,因为这似乎是导致我的问题的原因:

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.   

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

【问题讨论】:

    标签: flash actionscript-3 actionscript flex3 flexbuilder


    【解决方案1】:

    我从未尝试过打印...但这可能会有所帮助: pJob.addPage 期待一个精灵.. 所以为它提供一个像这样包装你的位图的:

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

    我希望它有效

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多