Hello guys, I’m working on mobile apps development as my intern project. I’ve referred to many threads in here for printJob coding and so far it went well. However, the printout seems to print 2 copy of it instead of 1.
My movie clip is a brochure (in JPG form) then turned into MovieClip and the actual size is about A4 paper size. However I’ve done scaling so that it scale with A4 page. Here is the code
[SIZE=2][FONT=courier new]function onPrint(e:MouseEvent):void {[/FONT][/SIZE]
[SIZE=2][FONT=courier new] [/FONT][/SIZE]
[SIZE=2][FONT=courier new] var myPrintJob:PrintJob = new PrintJob();[/FONT][/SIZE]
[SIZE=2][FONT=courier new] var mySprite: Sprite = new Sprite();[/FONT][/SIZE]
[SIZE=2][FONT=courier new] var opt:PrintJobOptions = new PrintJobOptions();[/FONT][/SIZE]
[SIZE=2][FONT=courier new] [/FONT][/SIZE]
[SIZE=2][FONT=courier new] [/FONT][/SIZE][FONT=courier new]myPrintJob.start();[/FONT]
[SIZE=2][FONT=courier new] [/FONT][/SIZE]
[SIZE=2][FONT=courier new] //Set sizing and print option before scaling[/FONT][/SIZE]
[SIZE=2][FONT=courier new] opt.printAsBitmap = true;[/FONT][/SIZE]
[SIZE=2][FONT=courier new] myPrintJob.selectPaperSize(“a4”)[/FONT][/SIZE]
[SIZE=2][FONT=courier new] myPrintJob.orientation = “landscape”[/FONT][/SIZE]
[SIZE=2][FONT=courier new] [/FONT][/SIZE]
[SIZE=2][FONT=courier new] //Scaling movie clip with printing page size[/FONT][/SIZE]
[SIZE=2][FONT=courier new] if (pic.width > myPrintJob.pageWidth) {[/FONT][/SIZE]
[SIZE=2][FONT=courier new] pic.width = myPrintJob.pageWidth;[/FONT][/SIZE]
[SIZE=2][FONT=courier new] pic.height = myPrintJob.pageHeight;[/FONT][/SIZE]
[SIZE=2][FONT=courier new] pic.scaleX = pic.scaleY;[/FONT][/SIZE]
[SIZE=2][FONT=courier new] }[/FONT][/SIZE]
[SIZE=2][FONT=courier new] [/FONT][/SIZE]
[SIZE=2][FONT=courier new] addChild(mySprite);[/FONT][/SIZE]
[SIZE=2][FONT=courier new] mySprite.addChild(pic);[/FONT][/SIZE]
[SIZE=2][FONT=courier new] [/FONT][/SIZE]
[SIZE=2][FONT=courier new] myPrintJob.addPage(mySprite);[/FONT][/SIZE]
[SIZE=2][FONT=courier new] myPrintJob.addPage(mySprite,null,opt); [/FONT][/SIZE]
[SIZE=2][FONT=courier new] [/FONT][/SIZE]
[SIZE=2][FONT=courier new] myPrintJob.send();[/FONT][/SIZE]
[SIZE=2][FONT=courier new] removeChild(mySprite);[/FONT][/SIZE]
[SIZE=2][FONT=courier new] mySprite.removeChild(pic);[/FONT][/SIZE]
[SIZE=2][FONT=courier new]}
I’m still wondering it prints for 2 copy instead of 1 only this is working code for printing using AS3. Hope anyone in the forum can take a look and correct me if there’s something wrong in that code. Cheers! ;)[/FONT][/SIZE]