Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE FLASH: Adobe Flash ForumAdobe Flash TutorialsAdobe Flash Video TutorialsWeb Streaming ForumAdobe Flash

Printing issue.

Cow Forums : Adobe Flash
Printing issue.
by Marc Poirier (Markyyyy) on Jun 21, 2008 at 5:10:29 pm

I've explored the tutorials and help files out there and was able to send a graphic to my printer YAHOOOOOO!!!!

BUT! the problem is the graphics is a red rectangle, and the printed document is a blue rectangle...

And before someone asks... all ink levels are full :)

here is the code...

btn.addEventListener(MouseEvent.CLICK,_Print);

var opt= new PrintJobOptions();
opt.printAsBitmap = true;
var myPrintJob:PrintJob = new PrintJob();
var mySprite:Sprite = new Sprite();
mySprite.graphics.beginFill(0xff0000);
mySprite.graphics.drawRect(0,0,400,200);
addChild(mySprite);



function _Print(evt:MouseEvent):void {
trace("printing started");
myPrintJob.start();
myPrintJob.addPage(mySprite,null,opt);
if (mySprite.height > myPrintJob.pageHeight)
{
mySprite.scaleY = .75;
}


if (myPrintJob.orientation == PrintJobOrientation.LANDSCAPE)
{
mySprite.rotation = 90;
}

var margine_height:Number = (myPrintJob.paperHeight - myPrintJob.pageHeight) / 2;
var margin_width : Number = (myPrintJob.paperWidth - myPrintJob.pageWidth) / 2;

myPrintJob.send();
}



Thanks!

Markyyyy

Respond to this post   •   Return to posts index

Re: Printing issue.
by Pieter Helsen on Jun 21, 2008 at 5:25:36 pm

First of all, try putting and endFill:


mySprite.graphics.beginFill(0xff0000);
mySprite.graphics.drawRect(0,0,400,200);
mySprite.graphics.endFill();


That probably won't be the problem though. So after that try and see what mySprite.graphics.beginFill(0x0000FF); does

Kind regards,
Pieter

Respond to this post   •   Return to posts index

Re: Printing issue.
by Marc Poirier on Jun 21, 2008 at 6:12:20 pm

Strangely, when I get the first screen, if I click on print as PDF.. the pdf comes up with a blue rectangle... If I use "open with pdfpen" then it comes out red...

the headache is starting :)

Mark



Respond to this post   •   Return to posts index


Re: Printing issue.
by Marc Poirier on Jun 21, 2008 at 6:22:31 pm

I did a "try" routine and i'm getting this error..

VerifyError: Error #1031: Scope depth is unbalanced. 2 != 3.
at printing_fla::MainTimeline/_Print()

I have no clue about that one..




Thanks!

Markyyyy

Respond to this post   •   Return to posts index

Re: Printing issue.
by Pieter Helsen on Jun 21, 2008 at 6:36:30 pm

Rename your print function. use printThis or something similar instead of _Print.

Also, strict typing requires that you do this:

var opt:PrintJobOptions = new PrintJobOptions();


Kind regards,
Pieter

Respond to this post   •   Return to posts index

Re: Printing issue.
by Marc Poirier on Jun 21, 2008 at 7:29:30 pm

OK.. great.. I'm not getting any errors anymore, but now it's not printing...
function PrintThis(evt:MouseEvent):void {
trace("printing started");
myPrintJob.start();
if (myPrintJob.start()){
try {
myPrintJob.addPage(mySprite,null,opt);
}
catch(e:Error) {
trace("error " + e);
//return
}
finally {
myPrintJob.send();
}

}



Thanks!

Markyyyy

Respond to this post   •   Return to posts index


Re: Printing issue.
by Pieter Helsen on Jun 21, 2008 at 7:32:56 pm

Did you change the eventHandler?


btn.addEventListener(MouseEvent.CLICK,PrintThis);


Kind regards,
Pieter

Respond to this post   •   Return to posts index

Re: Printing issue.
by Marc Poirier on Jun 21, 2008 at 7:39:07 pm

Yeap...

the script works... the printer will start moving, but won't print... (start works.. but it seems that send doesn't work.)

BUT!

if I remove the whole if..try...etc. part, then it will work... but in blue :(




Thanks!

Markyyyy

Respond to this post   •   Return to posts index

Re: Printing issue.
by Pieter Helsen on Jun 21, 2008 at 7:43:08 pm

Can you paste the full script again please? It's getting hard to keep track of the changes you made, heh.

Kind regards,
Pieter

Respond to this post   •   Return to posts index


Re: Printing issue.
by Marc Poirier on Jun 21, 2008 at 7:48:13 pm

lol...

here it is..

import flash.printing.PrintJob;
import flash.display.Sprite;


btn.addEventListener(MouseEvent.CLICK,PrintThis);

var opt:PrintJobOptions = new PrintJobOptions();
opt.printAsBitmap = true;
var myPrintJob:PrintJob = new PrintJob();
var mySprite:Sprite = new Sprite();
mySprite.graphics.beginFill(0xff0000);
mySprite.graphics.drawRect(0,0,400,200);
mySprite.graphics.endFill();
addChild(mySprite);


function PrintThis(evt:MouseEvent):void {
trace("printing started");
myPrintJob.start();
if (myPrintJob.start()){
try {
myPrintJob.addPage(mySprite,null,opt);
}
catch(e:Error) {
trace("error " + e);
//return
}
finally {
myPrintJob.send();
}

}


Thanks!

Markyyyy

Respond to this post   •   Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>


FORUMSTUTORIALSMAGAZINEDVDsBOOKSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]