Monday, August 23, 2004

how to use PrintJob class

How to use the Print job class

The new PrintJob class offers some kweel features
who are trying to print dynamic contents or different pages of
contents .You can put into use all ur programing skills to make the
content appear some wer on stage before the addPage() command takes it to
the printer spool.

A sample code will look like this
PrintObject.start() will return a boolean value,to check
for any error in printing.

print_btn.onRelease = function(){
my_pg= new PrintJob();
var myResult = my_pg.start();
if(myResult) {
// I am not writing a dynamic loop here,just to make your self understand
// how addPage() works .First of all make you self underStand that flash
//prints an area of the stage .So you should make any thing that you need
// to print shud be available some were on the stage.
// flash prints every thing as vector so you need to tell flash to print it
// as a bitmap.{printAsBitmap:true}

my_pg.addPage("print_mc",{xMin:0,xMax:468,yMin:0,yMax:485},{printAsBitmap:true},1);
print_mc.gotoAndStop(2);
my_pg.addPage("print_mc",{xMin:0,xMax:468,yMin:0,yMax:485},{printAsBitmap:true},2);

my_pg.send();
}
delete(my_pg);


}

//similarly you cod also print levels
// Starting 50 pixels to the right of 0,0 and 70 pixels down,
// print an area 500 pixels wide and 600 pixels high
// of frame 4 of level 5 in vector format
//(my_pj.addPage(5, {xMin:50,xMax:550,yMin:70,yMax:670},null, 4)



// applying the same logic you cod also print dynamic content in a text area//
//for that make sure that each time you add page you shud need to scroll the
//content up to the next position//


you can download the sample file "CLICK HERE"

No comments: