The Print Commands

I l @ ve RuBoard

There are two primary print commands. They have slightly different uses but work basically the same.

Print

The first is simply print . This command takes two parameters. The first is the target to be printed. Usually this is the main timeline, or _root . You can also use this . However, if you do want to print frames inside a movie clip, you can use a reference to that clip.

The second parameter is one of three options: bframe , bmovie , or bmax . These relate to how Flash scales the frames printed.

Flash scales the printable material up to the size where it fills the page as much as possible without distorting it. So if a frame is 550x400, it will most likely make the 550 pixels of the frame fit across the page. The vertical dimension will remain proportional.

If you use the bframe option, each frame printed scales to its own size to fill the page. If one frame fills 550x400 and a second frame has content that only fills 275x200, the second frame scales to twice the size of the first, so that they both fill their pages as much as possible.

If you use bmax as the second parameter, Flash examines all of the frame to be printed to determine which is the largest. It then chooses the scaling of all pages based on that one page. This keeps each frame the same relative size. So if a 550x400 screen is the largest, it fills the page. But a 275x200 screen in the same movie fills only half the page.

The third option is bmovie . In this case, you need to do a little more work. You need to create a frame in your movie that has a box on it. This box determines the maximum size to be printed. You must label this frame with a #b label. Then Flash uses the size of the box on this frame to determine the scaling to use on all frames printed. If there is something outside this area on a frame to be printed, it should not appear on the printout.

Here is an example of the print command:

 on (release) {     print(this,"bframe"); } 

As you can see, the boundary option is actually passed in as a string. You must put quotes around it.

You can see an example of the print command in action in the movie 20piechart.fla.

PrintAsBitmap

The companion command to print is printAsBitmap . This command works just like print , with the same two parameters.

The difference between print and printAsBitmap is that print actually sends vector graphics and fonts to the printer. The printer then re-creates the vectors and text when building the page.

On the other hand, printAsBitmap converts the entire screen to a large bitmap image and sends that to the printer.

The main advantage of printAsBitmap is that alpha transparencies can be printed; so if you have semitransparent graphics, you will need to use this. It also works with a wider variety of print devices.

The print command has the advantage of producing nice, smooth curves and text on higher-end printers. It may also be faster if printing over a network.

A good general rule to follow is to use printAsBitmap at times when you want to be assured that printing works and that the results mirror what is seen onscreen. Use print when accuracy is not critical or when you are making the movie for a controlled environment like a corporate intranet.

graphics/clock.gif

If you are streaming your movie over the Internet, note that printing should work only after all the frames you want printed have loaded. You may just want to check to make sure that the whole movie has been loaded before allowing the user to print. See Hour 23, "Managing Movie Streaming," to learn about streaming and how to detect whether a movie is fully loaded.


I l @ ve RuBoard


Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net