user1788175
user1788175

Reputation: 1518

AS3: How to print a full page Movieclip?

I am trying to print a movieclip on a button click. The movieclip originally is 300 x 400. I want to scale the movieclip to the highest size possible within the page and then print it.

Currently, I can print the movieclip using the following :

on(release)
{

   var pj:PrintJob = new PrintJob();
   pj.start();
   pj.addPage(my_mc);
   pj.send();

}

Thanks

Upvotes: 0

Views: 1211

Answers (1)

Strille
Strille

Reputation: 5781

You can first scale the movieclip so its size matches the maximum width and height of the page:

my_mc.width = pj.pageWidth;
my_mc.height = pj.pageHeight;

This will stretch the movie clip however, so to fix that we set the scale of both x and y to the smallest scale:

my_mc.scaleX = my_mc.scaleY = Math.min(my_mc.scaleX, my_mc.scaleY);

Final code:

var pj:PrintJob = new PrintJob();
pj.start();

var printArea : Rectangle = new Rectangle(0, 0, my_mc.width, my_mc.height);

my_mc.width = pj.pageWidth;
my_mc.height = pj.pageHeight;
my_mc.scaleX = my_mc.scaleY = Math.min(my_mc.scaleX, my_mc.scaleY);

pj.addPage(my_mc, printArea );
pj.send();

Upvotes: 2

Related Questions