Tip: Print control in Flash

Source: Internet
Author: User
Tags format include
Printing | tips | control

This estimate many people did not care about. But it's very useful. I'll put it up.

The class that is responsible for printing in Flash is PrintJob

Get to know it first.

Property:

Orientation:string The print orientation of the [read-only] image. The direction in which the image is printed. This property can be either "Landscape" or "portrait". Note that this property is only available if the Printjob.start () method is invoked.
The height (in points) of the actual printable area on the pageheight:number [read-only] page.
The width (in points) of the actual printable area on the pagewidth:number [read-only] page.
Paperheight:number [Read-only] paper total height (in points).
Paperwidth:number [Read Only] the total width of the paper (in points).

Usage:

AddPage (Target:object, [Printarea:object], [Options:object], [Framenum:number]): Boolean
Target:object-a number or string; the level or instance name of the movie clip you want to print. Pass a number to specify a level (for example, 0 represents a _root movie) or pass a string (enclosed in quotation marks ["]) to specify the instance name of the movie clip.

Printarea:object [optional]
An object that specifies the area to be printed, in the following format:

Program code:
{xmin:topleft, xmax:topright, Ymin:bottomleft, ymax:bottomright}

The coordinates specified for PrintArea represent screen pixels relative to the registration point of the _root movie clip (if target = 0) or the level or movie clip specified by Target. You must provide all four coordinates. Width (xmax-xmin) and height (ymax-ymin) must all be greater than 0.

Points are print units of measure, pixels are screen units of measure; the actual size of the points is fixed (1/72 inches), but the size of the pixels depends on the resolution of the particular screen. You can use the following conversion formula to convert inches or centimeters to twips or points (1 twips 1/20 points):

1 lb = 1/72 inches = 20 twips
1 inches = 72 lb = 1440 twips
1 cm = 567 twips
You cannot reliably convert between pixels and points, and the conversion rate depends on the screen and its resolution. For example, if the screen is set to display 72 pixels per inch, a pound is equal to one pixel.

Note: If you have previously used print (), Printasbitmap (), Printasbitmapnum (), or printnum () for printing from Flash, you may have used #b frame labels to specify the area you want to print. When using the AddPage () method, you must use the PrintArea parameter to specify the print area; #b frame labels will be ignored.

If the PrintArea parameter is omitted or the parameter is passed incorrectly, the entire stage area of target is printed. If you do not want to specify a value for PrintArea, but you want to specify a value for options or framenumber, pass NULL for PrintArea.

Options:object [optional]
A parameter that specifies whether to print as a vector or as a bitmap, using the following format:

{Printasbitmap:boolean}

The default value is False, which indicates the request vector printing. To print target as a bitmap, pass true for Printasbitmap. When determining which values to use, keep the following recommendations in mind:

If the content you want to print includes a bitmap image, use {printasbitmap:true} to include any transparency and color effects.
If the content does not include a bitmap image, omit this parameter or print the content in a higher-quality vector format using {printasbitmap:false}.
If the options are omitted or incorrectly passed, the vector is used to print. If you do not want to specify the value of options, but you want to specify the value of Framenumber, pass NULL for the options.

framenum:number [optional]
A number that specifies the frame to print; Passing framenumber does not cause the invocation of ActionScript on that frame. If this argument is omitted, the current frame in target is printed.

Note: If you have previously used print (), Printasbitmap (), Printasbitmapnum (), or printnum () for printing from Flash, you may have used #p frame labels on multiple frames to specify which pages to print. To print multiple frames using printjob.addpage (), you must issue a printjob.addpage () command for each frame; #p frame labels will be ignored. For a way to do this programmatically, see the Example section.

Return
Boolean-A Boolean value that returns true if the page is successfully sent to the print spooler, otherwise false.

Send (): Void
After the Printjob.start () and Printjob.addpage () methods are used, the spooled pages are sent to the printer.

Start (): Boolean
Displays the operating system's Print dialog box and starts background processing

PrintJob Constructors
var my_pj:printjob = new PrintJob ();

Example 1:

CODE:
PT2_MC for Movie clip name
var my_pj:printjob = new PrintJob ();
var Myresult:boolean = My_pj.start ();
if (Myresult) {
My_pj.addpage (PT2_MC);
My_pj.send ();
} else {
Trace ("No printing or printing failed");
}
Delete MY_PJ;

Example 2:

CODE:
PT2_MC for Movie clip name
Print results to three pages
var my_pj:printjob = new PrintJob (); Constructors
if (My_pj.start ()) {
var pagestoprint:number = 0;
if (My_pj.addpage (PT2_MC)) {
pagestoprint++;
}
if (My_pj.addpage (PT_MC)) {
pagestoprint++;
}
if (My_pj.addpage (PT_MC)) {
pagestoprint++;
}
if (pagestoprint>0) {
My_pj.send ();
}
}
Delete MY_PJ;



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.