Using PrintJob class

  • blanthycolino
  • Born
  • Born
  • blanthycolino
  • Posts: 1

Post 3+ Months Ago

Hi all

I'm new to AS3 and was never all that proficient at AS2. I'm working on a simple drag and drop piece and I want to be able to print the contents of the drag and drop.

I'm trying to use the PrintJob class that comes with CS4 but its not working.

Here's what I have...


Code: [ Select ]


function printContent(evt:MouseEvent) {
  var printJob:PrintJob = new PrintJob();

  if (printJob.start()) {

    if (content_MC.width>printJob.pageWidth) {

  1. print_btn.addEventListener(MouseEvent.CLICK,printContent);
  2. function printContent(evt:MouseEvent) {
  3.   var printJob:PrintJob = new PrintJob();
  4.   if (printJob.start()) {
  5.     if (content_MC.width>printJob.pageWidth) {
  6.       content_MC.width=printJob.pageWidth;
  7.       content_MC.scaleY=content_MC.scaleX;
  8.     }
  9.     printJob.addPage(content_MC);
  10.     printJob.send();
  11.   }
  12. }


Code: [ Select ]

// ActionScript Standard Library
// PrintJob object

intrinsic class PrintJob
  var orientation:String;
  var pageHeight:Number;
  var pageWidth:Number;
  var paperHeight:Number;
  var paperWidth:Number;

  function PrintJob();

  function addPage(target:Object, printArea:Object, options:Object, frameNum:Number):Boolean;
  function send():Void;
  function start():Boolean;
  1. //****************************************************************************
  2. // ActionScript Standard Library
  3. // PrintJob object
  4. //****************************************************************************
  5. intrinsic class PrintJob
  6. {
  7.   var orientation:String;
  8.   var pageHeight:Number;
  9.   var pageWidth:Number;
  10.   var paperHeight:Number;
  11.   var paperWidth:Number;
  12.   function PrintJob();
  13.   function addPage(target:Object, printArea:Object, options:Object, frameNum:Number):Boolean;
  14.   function send():Void;
  15.   function start():Boolean;
  16. }

I keep getting all sorts of errors prompting me to edit the PrintJob class. But as soon as I make an edit it comes up with one error after another an won't work.

What am I missing here? Shouldn't the CS4 PrintJob class just be right out of the box? Sorry if this is such a newbie question. But I am a newbie!

Any help would be greatly appreciated.

Thanks in advance!
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1825
  • Loc: In the Great White North

Post 3+ Months Ago

It should work right out of the box. Are you including a reference to that class at the beginning of your script?

The other thing I would check is to make sure you aren't calling the print class BEFORE anything actually exists inside the content_MC.

Timing is a really common problem for people getting used to actionscript. You might be surprised how often something not being loaded, instantiated etc will cause something seemingly unrelated to fail.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.