Tuesday, October 5, 2010

To Print a movieclip in actionscript2.0

on (press) {

// 72 pixels = 1 inch
// A4 printable height = 10.5 inches approx
var printableHeight = 10.5;
var objHeight = _root.targetMovieClip._height;
var objWidth = _root.targetMovieClip._width;
var numberOfPages = Math.ceil((objHeight/72)/printableHeight);
var pixelsPerPage = 72*printableHeight;

trace(numberOfPages)
var myPrint:PrintJob = new PrintJob();
myPrint.start();
for(i=0;i<numberOfPages;i++) {
yStart = i*pixelsPerPage;
yEnd = ((i+1)*pixelsPerPage) - 1;
printArea = {xMin:0, xMax:objWidth, yMin:yStart, yMax:yEnd};
myPrint.addPage(_root.targetMovieClip,printArea);
}
myPrint.send();
delete myPrint;

}


No comments:

Post a Comment