Re: [Flashcoders] Printing filters from the Flash Player
Hi Glen, This is quite similar to what we did. We first created a BitmapData of the scene and then printed that. Even posted about it :-) http://techblog.floorplanner.com/2008/10/22/printing-and-big-bitmaps/ But it feels like there should be an easier way... Gert-Jan 2008/10/25 Glen Pike [EMAIL PROTECTED] Hi, Here is some AS2 code that I wrote to do this - the _toPrint is a MovieClip containing lots of stuff with filters on. There is scaling too - depending on whether the user has chosen portrait or landscape - for later AS3 code, I worked out the orientation and rotated the printed image - not bitmapped though... The whole lot is rendered to a Bitmap, then printed. Hope this helps. I may even get round to blogging it one day :) Glen private function _print():Void { //start a print job with the _toPrint... // create PrintJob object 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; //we need to scale the object too! var h:Number = my_pj.pageHeight; var w:Number = my_pj.pageWidth; var xs = w / _toPrint._width; var ys = h / _toPrint._height; trace(page dimensions + w + , + h + scale + xs + , + ys + to print + _toPrint._xscale + , + _toPrint._yscale ); var _printWidth:Number; var _printHeight:Number; var scale:Number = (xs ys) ? xs : ys; if (xs ys) { _printWidth = Math.floor(xs * _toPrint._width); _printHeight = Math.floor(xs * _toPrint._height); } else { _printWidth = Math.floor(ys * _toPrint._width); _printHeight = Math.floor(ys * _toPrint._height); } trace(to print + _toPrint._xscale + , + _toPrint._yscale + = + _toPrint._width + , + _toPrint._height); // add specified area to print job //now do our bitmap thingy.. var printedImg:MovieClip = this.createEmptyMovieClip(printedImg, this.getNextHighestDepth()); printedImg.beginFill(0xff, 1); printedImg.moveTo(0, 0); printedImg.lineTo(my_pj.pageWidth, 0); printedImg.lineTo(my_pj.pageWidth, my_pj.pageHeight); printedImg.lineTo(0, my_pj.pageHeight); printedImg.lineTo(0, 0); printedImg.endFill(); var printBmp:BitmapData = new BitmapData(my_pj.pageWidth, my_pj.pageHeight, false, 0xff); printedImg.attachBitmap(printBmp, 1); var mtx:Matrix = new Matrix(); mtx.scale(scale, scale); printBmp.draw(_toPrint, mtx); // repeat once for each page to be printed if (my_pj.addPage(printedImg, null, {printAsBitmap:true})) { pagesToPrint++; } _toPrint._xscale = _toPrint._yscale = 100; if (pagesToPrint 0) { my_pj.send(); // print page(s) } printBmp.dispose(); delete printBmp; printedImg.unloadMovie(); } } Gert-Jan van der Wel wrote: Hi Jim, Yeah we tried the printAsBitmap option, but it didn't make much of a difference. We're now looking at creating a BitmapData and printing that. Maybe that works. Gert-Jan Op 24 okt 2008, om 15:17 heeft Jim McIntyre het volgende geschreven: Gert-Jan van der Wel wrote: Hi there, We use filters (shadows and glows) to make the scene look better. At some point a user can print what they've created, but the print shows no filters. Is there an easy way to get the filters on the print? Have you tried printAsBitmap? I found that was the only way to get some stuff to print the same way it was displayed, even when filters weren't involved (like some hand-drawn shadows using transparent fills). My project was written in AS2; I don't know whether the implications are different for code running in AVM2. (code simplified from my app, untested) -- private function printPoster():Void { var posterPrintJob:PrintJob = new PrintJob(); if (posterPrintJob.start()) { var pgsQueued:Number = 0; this.printPg._visible = true; //printPg is the MovieClip to print var printArea:Object = {xMin:0, xMax:printPg._width, yMin:0, yMax:printPg._height}; var printOptions:Object = {printAsBitmap:true}; if (posterPrintJob.addPage('printPg', printArea, printOptions)) { pgsQueued++; } if (pgsQueued) { posterPrintJob.send(); } } } -- ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Printing filters from the Flash Player
And how does this look in AS3?? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Glen Pike Sent: zaterdag 25 oktober 2008 0:30 To: Flash Coders List Subject: Re: [Flashcoders] Printing filters from the Flash Player Hi, Here is some AS2 code that I wrote to do this - the _toPrint is a MovieClip containing lots of stuff with filters on. There is scaling too - depending on whether the user has chosen portrait or landscape - for later AS3 code, I worked out the orientation and rotated the printed image - not bitmapped though... The whole lot is rendered to a Bitmap, then printed. Hope this helps. I may even get round to blogging it one day :) Glen private function _print():Void { //start a print job with the _toPrint... // create PrintJob object 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; //we need to scale the object too! var h:Number = my_pj.pageHeight; var w:Number = my_pj.pageWidth; var xs = w / _toPrint._width; var ys = h / _toPrint._height; trace(page dimensions + w + , + h + scale + xs + , + ys + to print + _toPrint._xscale + , + _toPrint._yscale ); var _printWidth:Number; var _printHeight:Number; var scale:Number = (xs ys) ? xs : ys; if (xs ys) { _printWidth = Math.floor(xs * _toPrint._width); _printHeight = Math.floor(xs * _toPrint._height); } else { _printWidth = Math.floor(ys * _toPrint._width); _printHeight = Math.floor(ys * _toPrint._height); } trace(to print + _toPrint._xscale + , + _toPrint._yscale + = + _toPrint._width + , + _toPrint._height); // add specified area to print job //now do our bitmap thingy.. var printedImg:MovieClip = this.createEmptyMovieClip(printedImg, this.getNextHighestDepth()); printedImg.beginFill(0xff, 1); printedImg.moveTo(0, 0); printedImg.lineTo(my_pj.pageWidth, 0); printedImg.lineTo(my_pj.pageWidth, my_pj.pageHeight); printedImg.lineTo(0, my_pj.pageHeight); printedImg.lineTo(0, 0); printedImg.endFill(); var printBmp:BitmapData = new BitmapData(my_pj.pageWidth, my_pj.pageHeight, false, 0xff); printedImg.attachBitmap(printBmp, 1); var mtx:Matrix = new Matrix(); mtx.scale(scale, scale); printBmp.draw(_toPrint, mtx); // repeat once for each page to be printed if (my_pj.addPage(printedImg, null, {printAsBitmap:true})) { pagesToPrint++; } _toPrint._xscale = _toPrint._yscale = 100; if (pagesToPrint 0) { my_pj.send(); // print page(s) } printBmp.dispose(); delete printBmp; printedImg.unloadMovie(); } } Gert-Jan van der Wel wrote: Hi Jim, Yeah we tried the printAsBitmap option, but it didn't make much of a difference. We're now looking at creating a BitmapData and printing that. Maybe that works. Gert-Jan Op 24 okt 2008, om 15:17 heeft Jim McIntyre het volgende geschreven: Gert-Jan van der Wel wrote: Hi there, We use filters (shadows and glows) to make the scene look better. At some point a user can print what they've created, but the print shows no filters. Is there an easy way to get the filters on the print? Have you tried printAsBitmap? I found that was the only way to get some stuff to print the same way it was displayed, even when filters weren't involved (like some hand-drawn shadows using transparent fills). My project was written in AS2; I don't know whether the implications are different for code running in AVM2. (code simplified from my app, untested) -- private function printPoster():Void { var posterPrintJob:PrintJob = new PrintJob(); if (posterPrintJob.start()) { var pgsQueued:Number = 0; this.printPg._visible = true; //printPg is the MovieClip to print var printArea:Object = {xMin:0, xMax:printPg._width, yMin:0, yMax:printPg._height}; var printOptions:Object = {printAsBitmap:true}; if (posterPrintJob.addPage('printPg', printArea, printOptions)) { pgsQueued++; } if (pgsQueued) { posterPrintJob.send(); } } } -- ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo
Re: [Flashcoders] Printing filters from the Flash Player
Nearly identical - you'd have to change _width to width, use the .graphics of a MC, etc. On Sat, Oct 25, 2008 at 6:22 AM, Cor [EMAIL PROTECTED] wrote: And how does this look in AS3?? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Glen Pike Sent: zaterdag 25 oktober 2008 0:30 To: Flash Coders List Subject: Re: [Flashcoders] Printing filters from the Flash Player Hi, Here is some AS2 code that I wrote to do this - the _toPrint is a MovieClip containing lots of stuff with filters on. There is scaling too - depending on whether the user has chosen portrait or landscape - for later AS3 code, I worked out the orientation and rotated the printed image - not bitmapped though... The whole lot is rendered to a Bitmap, then printed. Hope this helps. I may even get round to blogging it one day :) Glen private function _print():Void { //start a print job with the _toPrint... // create PrintJob object 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; //we need to scale the object too! var h:Number = my_pj.pageHeight; var w:Number = my_pj.pageWidth; var xs = w / _toPrint._width; var ys = h / _toPrint._height; trace(page dimensions + w + , + h + scale + xs + , + ys + to print + _toPrint._xscale + , + _toPrint._yscale ); var _printWidth:Number; var _printHeight:Number; var scale:Number = (xs ys) ? xs : ys; if (xs ys) { _printWidth = Math.floor(xs * _toPrint._width); _printHeight = Math.floor(xs * _toPrint._height); } else { _printWidth = Math.floor(ys * _toPrint._width); _printHeight = Math.floor(ys * _toPrint._height); } trace(to print + _toPrint._xscale + , + _toPrint._yscale + = + _toPrint._width + , + _toPrint._height); // add specified area to print job //now do our bitmap thingy.. var printedImg:MovieClip = this.createEmptyMovieClip(printedImg, this.getNextHighestDepth()); printedImg.beginFill(0xff, 1); printedImg.moveTo(0, 0); printedImg.lineTo(my_pj.pageWidth, 0); printedImg.lineTo(my_pj.pageWidth, my_pj.pageHeight); printedImg.lineTo(0, my_pj.pageHeight); printedImg.lineTo(0, 0); printedImg.endFill(); var printBmp:BitmapData = new BitmapData(my_pj.pageWidth, my_pj.pageHeight, false, 0xff); printedImg.attachBitmap(printBmp, 1); var mtx:Matrix = new Matrix(); mtx.scale(scale, scale); printBmp.draw(_toPrint, mtx); // repeat once for each page to be printed if (my_pj.addPage(printedImg, null, {printAsBitmap:true})) { pagesToPrint++; } _toPrint._xscale = _toPrint._yscale = 100; if (pagesToPrint 0) { my_pj.send(); // print page(s) } printBmp.dispose(); delete printBmp; printedImg.unloadMovie(); } } Gert-Jan van der Wel wrote: Hi Jim, Yeah we tried the printAsBitmap option, but it didn't make much of a difference. We're now looking at creating a BitmapData and printing that. Maybe that works. Gert-Jan Op 24 okt 2008, om 15:17 heeft Jim McIntyre het volgende geschreven: Gert-Jan van der Wel wrote: Hi there, We use filters (shadows and glows) to make the scene look better. At some point a user can print what they've created, but the print shows no filters. Is there an easy way to get the filters on the print? Have you tried printAsBitmap? I found that was the only way to get some stuff to print the same way it was displayed, even when filters weren't involved (like some hand-drawn shadows using transparent fills). My project was written in AS2; I don't know whether the implications are different for code running in AVM2. (code simplified from my app, untested) -- private function printPoster():Void { var posterPrintJob:PrintJob = new PrintJob(); if (posterPrintJob.start()) { var pgsQueued:Number = 0; this.printPg._visible = true; //printPg is the MovieClip to print var printArea:Object = {xMin:0, xMax:printPg._width, yMin:0, yMax:printPg._height}; var printOptions:Object = {printAsBitmap:true}; if (posterPrintJob.addPage('printPg', printArea, printOptions)) { pgsQueued++; } if (pgsQueued) { posterPrintJob.send
Re: [Flashcoders] Printing filters from the Flash Player
- Original Message - From: Cor [EMAIL PROTECTED] To: 'Flash Coders List' flashcoders@chattyfig.figleaf.com Sent: Saturday, October 25, 2008 11:22 AM Subject: RE: [Flashcoders] Printing filters from the Flash Player And how does this look in AS3?? That's for us to check after you've converted it Cor.. ;-) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Glen Pike Sent: zaterdag 25 oktober 2008 0:30 To: Flash Coders List Subject: Re: [Flashcoders] Printing filters from the Flash Player Hi, Here is some AS2 code that I wrote to do this - the _toPrint is a MovieClip containing lots of stuff with filters on. There is scaling too - depending on whether the user has chosen portrait or landscape - for later AS3 code, I worked out the orientation and rotated the printed image - not bitmapped though... The whole lot is rendered to a Bitmap, then printed. Hope this helps. I may even get round to blogging it one day :) Glen private function _print():Void { //start a print job with the _toPrint... // create PrintJob object 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; //we need to scale the object too! var h:Number = my_pj.pageHeight; var w:Number = my_pj.pageWidth; var xs = w / _toPrint._width; var ys = h / _toPrint._height; trace(page dimensions + w + , + h + scale + xs + , + ys + to print + _toPrint._xscale + , + _toPrint._yscale ); var _printWidth:Number; var _printHeight:Number; var scale:Number = (xs ys) ? xs : ys; if (xs ys) { _printWidth = Math.floor(xs * _toPrint._width); _printHeight = Math.floor(xs * _toPrint._height); } else { _printWidth = Math.floor(ys * _toPrint._width); _printHeight = Math.floor(ys * _toPrint._height); } trace(to print + _toPrint._xscale + , + _toPrint._yscale + = + _toPrint._width + , + _toPrint._height); // add specified area to print job //now do our bitmap thingy.. var printedImg:MovieClip = this.createEmptyMovieClip(printedImg, this.getNextHighestDepth()); printedImg.beginFill(0xff, 1); printedImg.moveTo(0, 0); printedImg.lineTo(my_pj.pageWidth, 0); printedImg.lineTo(my_pj.pageWidth, my_pj.pageHeight); printedImg.lineTo(0, my_pj.pageHeight); printedImg.lineTo(0, 0); printedImg.endFill(); var printBmp:BitmapData = new BitmapData(my_pj.pageWidth, my_pj.pageHeight, false, 0xff); printedImg.attachBitmap(printBmp, 1); var mtx:Matrix = new Matrix(); mtx.scale(scale, scale); printBmp.draw(_toPrint, mtx); // repeat once for each page to be printed if (my_pj.addPage(printedImg, null, {printAsBitmap:true})) { pagesToPrint++; } _toPrint._xscale = _toPrint._yscale = 100; if (pagesToPrint 0) { my_pj.send(); // print page(s) } printBmp.dispose(); delete printBmp; printedImg.unloadMovie(); } } Gert-Jan van der Wel wrote: Hi Jim, Yeah we tried the printAsBitmap option, but it didn't make much of a difference. We're now looking at creating a BitmapData and printing that. Maybe that works. Gert-Jan Op 24 okt 2008, om 15:17 heeft Jim McIntyre het volgende geschreven: Gert-Jan van der Wel wrote: Hi there, We use filters (shadows and glows) to make the scene look better. At some point a user can print what they've created, but the print shows no filters. Is there an easy way to get the filters on the print? Have you tried printAsBitmap? I found that was the only way to get some stuff to print the same way it was displayed, even when filters weren't involved (like some hand-drawn shadows using transparent fills). My project was written in AS2; I don't know whether the implications are different for code running in AVM2. (code simplified from my app, untested) -- private function printPoster():Void { var posterPrintJob:PrintJob = new PrintJob(); if (posterPrintJob.start()) { var pgsQueued:Number = 0; this.printPg._visible = true; //printPg is the MovieClip to print var printArea:Object = {xMin:0, xMax:printPg._width, yMin:0, yMax:printPg._height}; var printOptions:Object = {printAsBitmap:true}; if (posterPrintJob.addPage('printPg', printArea, printOptions)) { pgsQueued++; } if (pgsQueued) { posterPrintJob.send(); } } } -- ___ Flashcoders mailing
[Flashcoders] Printing filters from the Flash Player
Hi there, We use filters (shadows and glows) to make the scene look better. At some point a user can print what they've created, but the print shows no filters. Is there an easy way to get the filters on the print? Gert-Jan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Printing filters from the Flash Player
Gert-Jan van der Wel wrote: Hi there, We use filters (shadows and glows) to make the scene look better. At some point a user can print what they've created, but the print shows no filters. Is there an easy way to get the filters on the print? Have you tried printAsBitmap? I found that was the only way to get some stuff to print the same way it was displayed, even when filters weren't involved (like some hand-drawn shadows using transparent fills). My project was written in AS2; I don't know whether the implications are different for code running in AVM2. (code simplified from my app, untested) -- private function printPoster():Void { var posterPrintJob:PrintJob = new PrintJob(); if (posterPrintJob.start()) { var pgsQueued:Number = 0; this.printPg._visible = true; //printPg is the MovieClip to print var printArea:Object = {xMin:0, xMax:printPg._width, yMin:0, yMax:printPg._height}; var printOptions:Object = {printAsBitmap:true}; if (posterPrintJob.addPage('printPg', printArea, printOptions)) { pgsQueued++; } if (pgsQueued) { posterPrintJob.send(); } } } -- ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Printing filters from the Flash Player
Hi Jim, Yeah we tried the printAsBitmap option, but it didn't make much of a difference. We're now looking at creating a BitmapData and printing that. Maybe that works. Gert-Jan Op 24 okt 2008, om 15:17 heeft Jim McIntyre het volgende geschreven: Gert-Jan van der Wel wrote: Hi there, We use filters (shadows and glows) to make the scene look better. At some point a user can print what they've created, but the print shows no filters. Is there an easy way to get the filters on the print? Have you tried printAsBitmap? I found that was the only way to get some stuff to print the same way it was displayed, even when filters weren't involved (like some hand-drawn shadows using transparent fills). My project was written in AS2; I don't know whether the implications are different for code running in AVM2. (code simplified from my app, untested) -- private function printPoster():Void { var posterPrintJob:PrintJob = new PrintJob(); if (posterPrintJob.start()) { var pgsQueued:Number = 0; this.printPg._visible = true; //printPg is the MovieClip to print var printArea:Object = {xMin:0, xMax:printPg._width, yMin:0, yMax:printPg._height}; var printOptions:Object = {printAsBitmap:true}; if (posterPrintJob.addPage('printPg', printArea, printOptions)) { pgsQueued++; } if (pgsQueued) { posterPrintJob.send(); } } } -- ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Printing filters from the Flash Player
Hi, Here is some AS2 code that I wrote to do this - the _toPrint is a MovieClip containing lots of stuff with filters on. There is scaling too - depending on whether the user has chosen portrait or landscape - for later AS3 code, I worked out the orientation and rotated the printed image - not bitmapped though... The whole lot is rendered to a Bitmap, then printed. Hope this helps. I may even get round to blogging it one day :) Glen private function _print():Void { //start a print job with the _toPrint... // create PrintJob object 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; //we need to scale the object too! var h:Number = my_pj.pageHeight; var w:Number = my_pj.pageWidth; var xs = w / _toPrint._width; var ys = h / _toPrint._height; trace(page dimensions + w + , + h + scale + xs + , + ys + to print + _toPrint._xscale + , + _toPrint._yscale ); var _printWidth:Number; var _printHeight:Number; var scale:Number = (xs ys) ? xs : ys; if (xs ys) { _printWidth = Math.floor(xs * _toPrint._width); _printHeight = Math.floor(xs * _toPrint._height); } else { _printWidth = Math.floor(ys * _toPrint._width); _printHeight = Math.floor(ys * _toPrint._height); } trace(to print + _toPrint._xscale + , + _toPrint._yscale + = + _toPrint._width + , + _toPrint._height); // add specified area to print job //now do our bitmap thingy.. var printedImg:MovieClip = this.createEmptyMovieClip(printedImg, this.getNextHighestDepth()); printedImg.beginFill(0xff, 1); printedImg.moveTo(0, 0); printedImg.lineTo(my_pj.pageWidth, 0); printedImg.lineTo(my_pj.pageWidth, my_pj.pageHeight); printedImg.lineTo(0, my_pj.pageHeight); printedImg.lineTo(0, 0); printedImg.endFill(); var printBmp:BitmapData = new BitmapData(my_pj.pageWidth, my_pj.pageHeight, false, 0xff); printedImg.attachBitmap(printBmp, 1); var mtx:Matrix = new Matrix(); mtx.scale(scale, scale); printBmp.draw(_toPrint, mtx); // repeat once for each page to be printed if (my_pj.addPage(printedImg, null, {printAsBitmap:true})) { pagesToPrint++; } _toPrint._xscale = _toPrint._yscale = 100; if (pagesToPrint 0) { my_pj.send(); // print page(s) } printBmp.dispose(); delete printBmp; printedImg.unloadMovie(); } } Gert-Jan van der Wel wrote: Hi Jim, Yeah we tried the printAsBitmap option, but it didn't make much of a difference. We're now looking at creating a BitmapData and printing that. Maybe that works. Gert-Jan Op 24 okt 2008, om 15:17 heeft Jim McIntyre het volgende geschreven: Gert-Jan van der Wel wrote: Hi there, We use filters (shadows and glows) to make the scene look better. At some point a user can print what they've created, but the print shows no filters. Is there an easy way to get the filters on the print? Have you tried printAsBitmap? I found that was the only way to get some stuff to print the same way it was displayed, even when filters weren't involved (like some hand-drawn shadows using transparent fills). My project was written in AS2; I don't know whether the implications are different for code running in AVM2. (code simplified from my app, untested) -- private function printPoster():Void { var posterPrintJob:PrintJob = new PrintJob(); if (posterPrintJob.start()) { var pgsQueued:Number = 0; this.printPg._visible = true; //printPg is the MovieClip to print var printArea:Object = {xMin:0, xMax:printPg._width, yMin:0, yMax:printPg._height}; var printOptions:Object = {printAsBitmap:true}; if (posterPrintJob.addPage('printPg', printArea, printOptions)) { pgsQueued++; } if (pgsQueued) { posterPrintJob.send(); } } } -- ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Glen Pike 01326 218440 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list