beautypg.com

Adobe Flash Professional CC 2014 v.13.0 User Manual

Page 654

background image

Build a print job

Because you are spooling a print job to the user’s operating system between your calls to the PrintJob.start() and PrintJob.send() methods, and
because the PrintJob functions might temporarily affect the Flash Player internal view of onscreen Flash Professional content, implement print-
specific activities only between your calls to PrintJob.start() and PrintJob.send(). For example, the Flash Professional content should not interact
with the user between PrintJob.start() and PrintJob.send(). Instead, complete formatting of your print job, add pages to the print job, and send the
print job to the printer.

1. Create an instance of the print job object: new PrintJob().

2. Start the print job and display the print dialog box for the operating system: PrintJob.start().

3. Add pages to the print job (call once per page to add to the print job): PrintJob.addPage().

4. Send the print job to the printer: PrintJob.send().

5. Delete the print job: delete PrintJob.

The following example shows ActionScript code that creates a print job for a button:

myButton.onRelease = function()

{

var my_pj = new PrintJob();

var myResult = my_pj.start();

if(myResult){

myResult = my_pj.addPage (0, {xMin : 0, xMax: 400, yMin: 0,

yMax: 400});

myResult = my_pj.addPage ("myMovieClip", {xMin : 0, xMax: 400,

yMin: 400, yMax: 800},{printAsBitmap:true}, 1);

myResult = my_pj.addPage (1, null,{printAsBitmap:false}, 2);

myResult = my_pj.addPage (0);

my_pj.send();

}

delete my_pj;

}

Only one print job can run at any given time. A second print job cannot be created until one of the following events occurs with the previous
print job:

The print job is entirely successful and the PrintJob.send() method is called.

The PrintJob.start() method returns a value of false.

The PrintJob.addPage() method returns a value of false.

The delete PrintJob method is called.

Starting a print job

Calling the ActionScript 2.0 PrintJob.start() method spools the print job to the user’s operating system and prompts the user’s operating system
print dialog box to appear.

If the user selects an option to begin printing, the PrintJob.start() method returns a value of true. (The value is false if the user cancels the print
job, in which case the script should call only delete). If successful, the PrintJob.start() method sets values for the paperHeight, paperWidth,
pageHeight, pageWidth, and orientation properties.

Depending on the user’s operating system, an additional dialog box might appear until spooling is complete and the PrintJob.send function is
called: Make calls to PrintJob.addPage() and PrintJob.send() expeditiously. If ten seconds elapse between the PrintJob.start() function call and the
PrintJob.send() function call, which sends the print job to the printer, Flash Player effectively calls PrintJob.send(), causing any pages that are
added by using PrintJob.addPage() to be printed and spooling to stop.

When a new print job is constructed, the PrintJob() properties are initialized to 0. When PrintJob.start() is called, after the user selects the print
option in the operating system print dialog box, Flash Player retrieves the print settings from the operating system. The PrintJob.start() function
populates the following properties:

Property

Type

Unit

Notes

PrintJob.paperHeight

number

points

Overall paper height

PrintJob.paperWidth

number

points

Overall paper width

PrintJob.pageHeight

number

points

Height of actual printable area
on the page; does not include
any user-set margins

647