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).