beautypg.com

Controlling printing, Using the actionscript 2.0 printjob class – Adobe Flash Professional CS3 User Manual

Page 463

background image

FLASH CS3

User Guide

457

Printing from SWF files at runtime using ActionScript 2.0

You can add printing functionality to Flash documents that lets users print from Flash Player. You can use the
ActionScript™ PrintJob class, or you can use the print() or printAsBitmap() ActionScript functions. Users can also
access the Flash Player context menu and select the Print command there. Additionally, users can print from a
browser, rather than from Flash Player, by selecting a command such as File > Print from the browser window.
However, printing from Flash Player directly, rather than from a browser window Print menu, offers several advan-
tages, including the following:

Users can print all frames or certain frames that you’ve labeled as printable from Flash Player. Additionally, you
can set the print area of a frame.

You can specify that content print as vector graphics (to take advantage of higher resolution) or as bitmaps (to
preserve transparency and color effects).

The ActionScript PrintJob object improves upon the print() and printAsBitmap() functions by adding the ability
to print dynamically rendered pages as a single print job. The PrintJob object also provides the user’s printer
settings, which can be used to format reports specifically for the user.

Flash Player versions earlier than 4.0.25 (Windows) or 4.0.20 (Macintosh) do not support printing frames directly.
Flash Player 7 and later supports the PrintJob class.

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

Controlling printing

To control what users can print, remember the following items as you set up documents and movie clips for printing:

Adjust the page layout in any frames that you designate as printable to match the desired printed output. Using
Flash Player, you can print all shapes, symbols, bitmaps, text blocks, and text fields. Levels in a SWF file are not
composited on print output.

The printer driver uses the HTML settings for dimension, scale, and alignment in the Publish Settings dialog box.
Use these settings to control the print layout.

The selected frames print as they appear in the movie clip symbol. Let users print a movie clip that is not visible
in a browser by using the Actions panel to set the movie clip’s

_visible

property to

false

. Changing the property

of a movie clip with the

setProperty

action, tweening, or any transformation tool does not affect how a movie

clip prints.

For a movie clip to be printable, it must be on the Stage or pasteboard and it must be given an instance name.

All elements must be fully loaded to print. Use the movie clip

_framesloaded

property to check whether the

printable content is loaded. For more information, see _framesloaded (MovieClip._framesloaded property) in the
ActionScript 2.0 Language Reference.

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

Using the ActionScript 2.0 PrintJob class

The ActionScript PrintJob class, in addition to improving print functionality available with the

print()

method,

lets you render dynamic content at runtime, prompt users with a single print dialog box, and print an unscaled
document with proportions that map to the proportions of the content. This capability is useful for rendering and
printing external dynamic content, such as database content and dynamic text.