View comments | RSS feed

Printing a page

You use an instance of the PrintJob class to handle printing. To print a basic page through Flash Player, you use these four statements in sequence:

So, for example, a very simple print job script may look like the following (including package, import and class statements for compiling):

package
{
    import flash.printing.PrintJob;
    import flash.display.Sprite;

    public class BasicPrintExample extends Sprite
    {
        var myPrintJob:PrintJob = new PrintJob();
        var mySprite:Sprite = new Sprite();

        public function BasicPrintExample()
        {
            myPrintJob.start();
            myPrintJob.addPage(mySprite);
            myPrintJob.send();
        }
    }
}

NOTE

 

This example is intended to show the basic elements of a print job script, and does not contain any error handling. To build a script that responds properly to a user canceling a print job, see Working with exceptions and returns.

If you need to clear a PrintJob object's properties for any reason, set the PrintJob variable to null (as in myPrintJob = null).


Flash CS3


Comments


No screen name said on Aug 16, 2007 at 3:24 AM :
I used thise Action but the Printer result Is White Paper

function prt(MouseEvent) {
var pr = new PrintJob();
var sp=new Sprite();
var opt= new PrintJobOptions();
opt.printAsBitmap = true;
pr.start();
pr.addPage(sp, null, opt);
pr.send();
}
No screen name said on Nov 17, 2007 at 11:43 AM :
There is nothing in the sprite.

try this (This would draw a red circle, so when you print you should get a circle)

function prt(MouseEvent) {
var pr = new PrintJob();
var sp=new Sprite();

//drawing a circle
sp.graphics.beginFill(0xff0000);
sp.graphics.drawCircle(40, 40, 40);
//adding the sprite to the display hierarchy
addChild(sp);

var opt= new PrintJobOptions();
opt.printAsBitmap = true;
pr.start();
pr.addPage(sp, null, opt);
pr.send();
}

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000332.html