Skip to main content
Participating Frequently
April 23, 2009
Question

Print Function

  • April 23, 2009
  • 1 reply
  • 426 views

Hi

I am trying to create a print button and i just need some help with the action script.  Print (Target, type) is the function i know target is the name of the file i want to print but can someone tell me what type is for.

Thanks

Natasha

This topic has been closed for replies.

1 reply

Known Participant
April 23, 2009

Hi,

I just learned how to do that.  The code in the actionScript help files were pretty stratght forward.  I use Flash 8 ActionScript2.

Here's what I did.  This script is inserted on the main timeline  I made a movieclip button with _over, _up, _down, and _quit labels.  The resr is from the actionScript help text.

stop();

// for the movieclip acting as a button
var printed:Boolean = false;
printBtn.onRollOver = function() {
printBtn.gotoAndStop("_over");
};
printBtn.onRollOut = function() {
if (!printed) {
  printBtn.gotoAndPlay("_quit");
}
};
printBtn.onReleaseOutside = function() {
if (!printed) {
  printBtn.gotoAndPlay("_quit");
}
};
printBtn.onPress = function() {
printBtn.gotoAndStop("_down");
};
printBtn.onRelease = function() {
printed = true;
printBtn.gotoAndStop("_up");


// create PrintJob object  // this starts the actionScript help text


var my_pj:PrintJob = new PrintJob();
// display print dialog box, but only initiate the print job
// if start returns successfully.
if (my_pj.start()) {
  // use a variable to track successful calls to addPage
  var pagesToPrint:Number = 0;
  // add specified area to print job
  // repeat once for each page to be printed

// "page" is the name of the movieclip to print- use the quotes
  if (my_pj.addPage("page")) {
   pagesToPrint++;
  }
  /*  if (my_pj.addPage([params])) {
  pagesToPrint++;
  }
  if (my_pj.addPage([params])) {
  pagesToPrint++;
  }
  */
  // send pages from the spooler to the printer, but only if one or more
  // calls to addPage() was successful. You should always check for successful
  // calls to start() and addPage() before calling send().
  if (pagesToPrint>0) {
   my_pj.send();
   // print page(s)
  }
}
// clean up          
delete my_pj;
// delete object
};

hope this helps.