O'Reilly logo

Flash 8 Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

21.9. Printing Flash Content

Problem

You want to print content from Flash.

Solution

Use the PrintJob ActionScript class.

Discussion

When you want to print Flash content, you always have the option of allowing the user to select the Print option from the Flash Player context menu. However, that is neither an obvious UI action for the user, nor does it offer much control over what will print. Instead, the better way to manage printing of Flash content is to use the PrintJob class.

The PrintJob class enables you to print one or more pages of content while prompting the user with just one dialog box. The PrintJob class enables you to print content from any frame of any movie clip, and you can even specify printable regions and how to optimize the printing depending on whether the content uses bitmaps or vectors.

The first step when working with the PrintJob class is to construct a new instance, and assign that to a variable. You can construct a new instance by using the constructor method, as in the following example:

	var pjContent:PrintJob = new PrintJob();

Next, call the start( ) method in order to prompt the user with the Print dialog box. Flash doesn’t allow you to print unless the user clicks OK from the dialog box. The start( ) method is synchronous. That means that the ActionScript interpreter halts when the start( ) method is called until the user clicks OK or Cancel from the Print dialog box. When the user clicks one of the buttons, a Boolean value is returned to Flash. If the user ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required