Actionscript 3 (AS3) Printing issue with large SWFs
Posted: Thu Feb 26, 2009 11:50 am
Attempting to call printTheDocument() in the onLoaded event listener works fine for small files but if it's greater than 800kbp or so, something is still loading that prevents you from printing.
p2f.addEventListener("onLoaded", function (evt) {
p2f.printTheDocument();
});
I am forced to use a timer that attempts to call printTheDocument() every few seconds. I added an onPrinted event listener to stop the timer. The problem is when the print dialog box is dismissed via "Print" or "Cancel" the timer goes off one last time before the onPrinted listener can go off, because the dialog apparently halts the timer while it's up and it sets off as soon as the dialog is dismissed. This causes the print dialog to open a second time.
var myTimer;
p2f.addEventListener("onPrinted", function (evt) {
myTimer.stop();
});
p2f.addEventListener("onLoaded", function (evt) {
p2f.printTheDocument();
myTimer = new Timer(3000); // 3 seconds should be good
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, function (evt) {
p2f.printTheDocument();
});
});
What is needed is for the printTheDocument() function to return a success/failure or for a new onLoaded type event function that goes off when printing is actually accessible.
Anyone got any solutions?
Print2Flash, will you address my suggestions or how I can get around this?
p2f.addEventListener("onLoaded", function (evt) {
p2f.printTheDocument();
});
I am forced to use a timer that attempts to call printTheDocument() every few seconds. I added an onPrinted event listener to stop the timer. The problem is when the print dialog box is dismissed via "Print" or "Cancel" the timer goes off one last time before the onPrinted listener can go off, because the dialog apparently halts the timer while it's up and it sets off as soon as the dialog is dismissed. This causes the print dialog to open a second time.
var myTimer;
p2f.addEventListener("onPrinted", function (evt) {
myTimer.stop();
});
p2f.addEventListener("onLoaded", function (evt) {
p2f.printTheDocument();
myTimer = new Timer(3000); // 3 seconds should be good
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, function (evt) {
p2f.printTheDocument();
});
});
What is needed is for the printTheDocument() function to return a success/failure or for a new onLoaded type event function that goes off when printing is actually accessible.
Anyone got any solutions?
Print2Flash, will you address my suggestions or how I can get around this?