13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Printing<br />

Printing for landscape or portrait ori<strong>en</strong>tation<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Because Flash Player and AIR can detect the settings for ori<strong>en</strong>tation, you can build logic into your ActionScript to<br />

adjust the cont<strong>en</strong>t size or rotation in response to the printer settings, as the following example illustrates:<br />

if (myPrintJob.ori<strong>en</strong>tation == PrintJobOri<strong>en</strong>tation.LANDSCAPE)<br />

{<br />

mySprite.rotation = 90;<br />

}<br />

Note: If you plan to read the system setting for cont<strong>en</strong>t ori<strong>en</strong>tation on the paper, remember to import the<br />

PrintJobOri<strong>en</strong>tation class. The PrintJobOri<strong>en</strong>tation class provides constant values that define the cont<strong>en</strong>t ori<strong>en</strong>tation on<br />

the page. You import the class using the following statem<strong>en</strong>t:<br />

import flash.printing.PrintJobOri<strong>en</strong>tation;<br />

Responding to page height and width<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Using a strategy that is similar to handling printer ori<strong>en</strong>tation settings, you can read the page height and width settings<br />

and respond to them by embedding some logic into an if statem<strong>en</strong>t. The following code shows an example:<br />

if (mySprite.height > myPrintJob.pageHeight)<br />

{<br />

mySprite.scaleY = .75;<br />

}<br />

In addition, a page’s margin settings can be determined by comparing the page and paper dim<strong>en</strong>sions, as the following<br />

example illustrates:<br />

margin_height = (myPrintJob.paperHeight - myPrintJob.pageHeight) / 2;<br />

margin_width = (myPrintJob.paperWidth - myPrintJob.pageWidth) / 2;<br />

Advanced printing techniques<br />

Adobe AIR 2 and later<br />

Starting with Adobe AIR 2, the PrintJob class has additional properties and methods, and three additional classes are<br />

supported: PrintUIOptions, PaperSize, and PrintMethod. These changes allow additional printer workflows and give<br />

authors greater control over the printing process. Changes include:<br />

Page setup dialogs: Both standard and custom page setup dialogs can be displayed. The user can set page ranges,<br />

paper size, ori<strong>en</strong>tation, and scaling before printing.<br />

Print view: A viewing mode can be created which accurately shows paper size, margins, and the position of cont<strong>en</strong>t<br />

on the page.<br />

Restricted printing: Authors can restrict printing options, such as the range of printable pages.<br />

Quality options: Authors can adjust the print quality for a docum<strong>en</strong>t and allow the user to select resolution and<br />

color options.<br />

Last updated 6/6/2012<br />

928

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!