beautypg.com

Adding pages to a print job – Adobe Flash Professional CS3 User Manual

Page 465

background image

FLASH CS3

User Guide

459

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

orien-

tation

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:

Note: For information on printing from SWF files at runtime using ActionScript 3.0, see “Printing” in Programming
ActionScript 3.0.

Adding pages to a print job

You add pages to your print job with the ActionScript 2.0

PrintJob.addPage()

method. Although the method can

include as many as four parameters, the only required parameter is

target/level

. The three optional parameters

are

printArea

,

options

, and

frameNum

.

If you are not using a particular optional parameter but are using other optional parameters, use

NULL

in place of the

excluded optional parameter.

With all four parameters, the function uses the following syntax:

MyPrintJob.addPage(target[,printArea:Object, options:Object, frameNum:Number]):boolean;

If you provide an invalid parameter, the print job uses default parameter values.

Each call to add a new page is unique, which lets you modify parameters without affecting previously set parameters.
For example, you can specify that one page print as a bitmap image and another page print as a vector graphic. You
can add as many new pages to your print job as the print job requires. One call to add a page equals one printed page.

Property

Type

Unit

Notes

PrintJob.paper-
Height

number

points

Overall paper height

PrintJob.paper-
Width

number

points

Overall paper width

PrintJob.page-
Height

number

points

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

PrintJob.page-
Width

number

points

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

PrintJob.orien-
tation

string

n/a

Portrait or landscape
orientation