advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the code for this article
Do you know of any other strategies, tips, or pitfalls for using Flash’s printing features? Tell us about what you learned and new ideas you have in our Web Development Forum.
Partners & Affiliates
advertisement
advertisement
advertisement
Rate this item | 0 users have rated this item.
Email this articleEmail this article
 
Powerful Printing in Flash MX 2004
ActionScript 2.0's new PrintJob class allows you to add robust printing support to your Flash-based Web applications. Learn how to use this new feature—along with a code design that allows on-the-fly interface assembly on any movie clip.  

advertisement
t is no longer neccessary to creatively twist and bend Flash's printing APIs to perform the more complex printing tasks like multi-page printing. Thanks to ActionScript 2.0 and Flash Player 7, you now have direct access to a rich set of print functionality. This article explores these powerful new functions and discusses how to structure application code to take full advantage of them.


This previous article, discussing Flash Player 5, outlined a set of code strategies for printing in Flash and those techniques have aged well. Reading the previous article isn't a prerequisite, but it's not a bad idea, as this article uses the same design strategy to organize application code in a manner that makes printing even simpler and the code even more maintainable.

The PrintJob Class
The big change introduced by Flash Player 7 is the PrintJob class. PrintJob has three methods: start(), addPage(), and send() which are called during the course of printing. The standard boilerplate code looks like this:


var printJob:PrintJob = new PrintJob();
if (printJob.start()) {
var numPages:Number = 0;
if (printJob.addPage(aMovieClip)) {
numPages ++;
}
// etc.
if (numPages> 0) {
printJob.send();  // print page(s)
}
}
delete printJob;  
The numPages variable counts the pages as they are added, and ensures that at least one call to addPage() succeeds before it calls PrintJob.send(). In addition, the addPage() method can take three optional parameters after the initial movie clip parameter (which is required). Those additional arguments are: a bounding box for the print area, a parameter letting Flash know whether to print as vector or bitmap, and a frame number to print. While ActionScript 2.0's documentation covers those parameters in more depth, using the techniques described below should mean that you won't have to use those additional parameters very often.

Though the actual ActionScript printing classes and methods are straightforward, how best to use them is not. The previous article outlines a technique for printing that involves copying movie clips dynamically to off-screen, pre-drawn printing interfaces—instead of printing what was on the actual user-interface. This strategy provides a much more stable and controllable printing process.

  Next Page: A Flash Drawing Application


Page 1: IntroductionPage 3: Adding Drawing Code
Page 2: A Flash Drawing Application 
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES