You use an instance of the PrintJob class to handle printing. To print a basic page through Flash Player or AIR, 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();
}
}
}
If you need to clear a PrintJob object's properties for any reason, set the PrintJob variable to null (as in myPrintJob = null).