Using PrintJob class

  • blanthycolino
  • Born
  • Born
  • No Avatar
  • Joined: Mar 27, 2010
  • Posts: 1
  • Status: Offline

Post March 27th, 2010, 12:39 pm

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...

THE BUTTON HANDLER

Code: [ Select ]

print_btn.addEventListener(MouseEvent.CLICK,printContent);

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

  if (printJob.start()) {

    if (content_MC.width>printJob.pageWidth) {
      content_MC.width=printJob.pageWidth;
      content_MC.scaleY=content_MC.scaleX;
    }

    printJob.addPage(content_MC);
    printJob.send();
  }
}
  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. }



THE PrintJob CLASS INCLUDED IN CS4

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!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 27th, 2010, 12:39 pm

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post March 29th, 2010, 2:54 pm

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.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 49 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.