User Guide
Flash Player tasks and system printing 489
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();
}
}
}
Flash Player tasks and system printing
Because Flash Player dispatches pages to the operating system’s printing interface, you should
understand the scope of the tasks managed by Flash Player, and the tasks managed by an
operating system’s own printing interface. Flash Player can initiate a print job, read some of a
printer’s page settings, pass the content for a print job to the operating system, and verify if
the user or system has cancelled a print job. Other processes, such as displaying printer
specific dialog boxes, cancelling a spooled print job, or reporting on the printer’s status, are all
handled by the operating system. Flash Player is able to respond if there is a problem initiating
or formatting a print job, but can report back only on certain properties or conditions from
the operating system’s printing interface. As a developer, your code should have the ability to
respond to these properties or conditions.
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” on page 490.