advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 3.6/5 | Rate this item | 8 users have rated this item.
Powerful Printing in Flash (cont'd)
Controlling the Printout Format
You still need to add the exhibit info and date to the printout. Here is one way to print a movie clip that is on the user interface: add a couple of textfields to the drawingArea clip. By default, make these fields invisible and then immediately before printing, make them visible. Right after printing, turn them off again.
advertisement

This solution is not ideal because users will see an awkward flickering as the textfields appear and disappear just before and after printing. Also, in general, there is no guaruntee that Flash will send the image of the drawingArea clip to the printer at the exact moment the textfields are visible. If Flash is a fraction of a second late, they may not appear in the printout.

 
Figure 3: The Printing Clip. Notice the printing clip is located outside the visible area of the movie.

The solution, as I mentioned at the beginning, is to use an off-screen movie clip. Copy what is on the drawingArea clip to a movie clip outside the visible area, and print that off-screen clip. It turns out that Flash is perfectly capable of printing clips that are beyond the borders of the visible area (see Figure 3).

Create another clip called printingClip. Make it the same size as drawingClip, but keep it out of the visible area of the movie. To that clip, add a pair of TextFields at the top for the exhibit info and date. To further improve the look of the printout, you can stick in a border as well.

The print button needs to make a copy of what is on the current drawing area. To do this, change the print button handler:


printButton.onPress = function() {
	// we need to make a  copy of circleCount circles
for (var i = 0; i < circleCount; i++) {
	// first find the circle clip on the drawing area
		var drawnCircle = eval("drawingArea.circle" + i);
	
	// create a new circle clip on the print area
	printingArea.attachMovie("circle","circle" + i,i);
	var printCircle = eval("printingArea.circle" + i);
		
	// move the new circle clip to the same position as the other clip
	printCircle._x = drawnCircle._x;
	printCircle._y = drawnCircle._y;
	
	// set color of the new circle clip
	var drawnCircleColor = new Color(drawnCircle);
	var printCircleColor = new Color(printCircle);
	printCircleColor.setRGB(drawnCircleColor.getRGB());			
}
The final movie includes a date field on the printout, so just before calling print(), fill in the date:

printingArea.dateField.text = new Date();
Then call print():

print(printingArea,"bframe");
There you have it! A print UI that you can customize to support your printing needs. Plus, if the client has new formatting requests, you can easily manipulate this printing interface without affecting the main UI.

Previous Page: Printing Options  
Eric Jansson is the lead software engineer at ActiveInk (www.activeink.net), a developer of interactive online curriculum powered by the ActiveInk Network delivery platform. One of his focuses in recent years has been integrating Flash into Web-based applications, to which he brings his years of experience working with Java and object-oriented design. He can be reached at eric.jansson@activeink.net.
Page 1: IntroductionPage 3: Printing Options
Page 2: Your Sample Flash MoviePage 4: Controlling the Printout Format
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs