views:

41

answers:

1

Following up from: http://stackoverflow.com/questions/3021557/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?

A: 

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

Antriel