Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

macromedia flash mx - Reinhardt R.

Reinhardt R., Lott J macromedia flash mx - John Wiley & Sons, 2004. - 987 p.
ISBN 0-7645-4354-7
Download (direct link): macromediaflash2004.pdf
Previous << 1 .. 251 252 253 254 255 256 < 257 > 258 259 260 261 262 263 .. 419 >> Next

To see the effects of scaling a target with printed output, complete the following steps:
1. Open the starter file and save it as PrintJob_scale_100.fla.
2. Create a new layer named mcContent. Place this layer at the bottom of the layer stack.
3. On frame 1 of this new layer, drag an instance of the contentClip symbol from the Library to the stage. Using the Property inspector, name this instance mcContent and set the width to 282 pixels and the height to 365 pixels (see Figure 22-3). If you whip out your calculator, you can see that these dimensions use the same aspect ratio as an 8.5" x 11" piece of paper (365 x 282 = 1.29). Using the conversion formula, this artwork, at 282 x 265, will print at 3.9" x 5" on the page.
4. Select frame 1 of the actions layer and open the Actions panel (F9). Add the bold code shown in Listing 22-3.
of this book's CD-ROM.
book's CD-ROM.
This code works exactly the same as the last example, except that the target is changed in the addPage() method.
550 Part V ¦ The Movie Classes
Figure 22-3: The settings for the mcContent instance
Listing 22-3: Printing the mcContent Instance at Its Fixed Size
this.startPrint = function(oEvent:Object):Void { trace(">>> BEGIN startPrint() >>>"); var pjOutput:PrintJob = new PrintJob(); var bPrintInit:Boolean = pjOutput.start(); trace("\tbPrintInit:\t\t" + bPrintlnit); for(var i:String in pjOutput){ var nPropLen:Number = i.length;
var sTabSuffix:String = nPropLen <= 10 ? ":\t\t" : ":\t"; trace("\t" + i + sTabSuffix + pjOutput[i]);
}
if(bPn'ntInit){
trace("\tprinting mcContent...”);
pjOutput.addPage(mcContent);
pjOutput.send();
}
trace("<<< END startPrint() <<<");
};
cbtPrint.addEventListener("click", this.startPrint);
Chapter 22 ¦ The PrintJob Class 551
5. Save your document and test it. When you click the Print button in the Flash movie, the system’s Print dialog box will open. If you click the Print (or OK) button, the mcContent clip will be printed at the size indicated in Step 3.
6. Now you will scale the target to fit the paper size selected by the user. This operation requires that you change the target’s _width and _height properties to fill the page. Select frame 1 of the actions layer and add the bold code shown in Listing 22-4.
In this new code, you use the pageWidth and pageHeight values returned to the pjOutput instance after a successful start() method has initiated. These values are stored in the nPageWidth and nPageHeight variables, respectively.
The mcProps object is created to store the original width and height values of the mcContent instance. Because you will be changing the width and height for the print output only, you want to reset the instance to these original values after printing is finished.
The nPageWidth and nPageHeight values are then applied to the mcContent’s _width and _height properties, respectively. At these new dimensions, the output will fill the entire printed page.
Web This example assumes that you are using 8.5" x 11" paper with a portrait orientation. Look at
Resource www.flashsupport.com/articles for a more detailed example that shows you how to adjust the size and rotation of the target clip based on the user's selected paper size and orientation.
After the output is sent to the printer, another with() statement resets the _width and _height properties to their original values, as stored in the mcProps object.
Listing 22-4: Printing the mcContent Instance to Fill the Page
this.startPrint = function(oEvent:Object) { trace(">>> BEGIN startPrint() >>>"); var pjOutput:PrintJob = new PrintJob(); var bPrintInit:Boolean = pjOutput.start(); trace("\tbPrintInit:\t\t" + bPrintlnit); for (var i in pjOutput) {
var nPropLen:Number = i.length;
var sTabSuffix:String = nPropLen <= 10 ? ":\t\t" : ":\t"; trace("\t" + i + sTabSuffix + pjOutput[i]);
}
if (bPrintlnit) {
trace("\tprinting mcContent..."); var nPageWidth:Number = pjOutput.pageWidth; var nPageHeight:Number = pjOutput.pageHeight; var mcProps:Object = {
width: mcContent._width, height: mcContent._height
};
Continued
552 Part V ¦ The Movie Classes
Listing 22-4 (continued)
with(mcContent){
_width = nPageWidth;
_height = nPageHeight;
}
pjOutput.addPage(ncContent);
pjOutput.send();
with(mcContent){
_width = mcProps.width;
_height = mcProps.height;
}
}
trace("<<< END startPrint() <<<");
};
cbtPrint.addEventListener("click", this.startPrint);
7. Save your document as PrintJob_scale_101.fla and test the movie. When you click the Print button in the Flash movie and the Print button in the Print dialog box, the mcContent instance will print to the full size of an 8.5" x 11" piece of paper.
8. Now you examine how the oPrintArea parameter of the addPage() method can affect the printed output from a Flash movie. For this example, you will use the oPrintArea parameter to selectively print the flashsupport.com logo from the mcContent instance. Select frame 1 of the actions layer and open the Actions panel (F9). Add the bold code shown in Listing 22-5.
Previous << 1 .. 251 252 253 254 255 256 < 257 > 258 259 260 261 262 263 .. 419 >> Next