Dec 08

PrintJob has been giving me a couple of problems lately, one of them was proper placement of the objects on page. This post discusses the fix

NOTE: I have not been able to confirm the behavior described here, may be it was just something i was doing wrong. However i am posting it here so that if it’s really a problem, this fix might help

Say, there’s a Sprite/MovieClip of a standard page size (say A4), say it’s called ‘p’, naturally you would print it as:

var pj:PrintJob = new PrintJob();
if(pj.start())
{
pj.addPage(p); // p is the Sprite/MovieClip of full page size
pj.send();
}

Say you had an rectangle (the only object in the Sprite) right in the middle of the sprite, since the sprite’s size equals the page size, you’ll expect the rectangle to be printed in the middle of the page, right? Surprise! it gets printed in the top left corner.

What happened here is that actionscript aligned the first drawn pixel (the top left corner of the rectangle) to the top left corner of the page. To workaround, you may draw an invisible rectangle of the full page size to the Sprite so that everything gets printed neatly. here’s what you would do:

var pj:PrintJob = new PrintJob();
if(pj.start())
{
p.graphics.lineStyle(1, 0xFFFFFF, 0);
p.graphics.drawRect(0, 0, PageWidth, PageHeight);

pj.addPage(p); // p is the Sprite/MovieClip of full page size
pj.send();
}

written by ishaq

Dec 08

I just finished Who Moved My Cheese by Dr. Spencer Johnson (I hope I spelled that right :) ) after it had been lying around for about 6 months. It’s a great short story, takes about 45 minutes to complete and nicely describes different behaviors when a change is encountered.

I didn’t like the discussion in the later part of the book though, It seems, may I say, too artificial.

And btw, while I am not Sniff or Scurry, I do try to be Haw. (if you don’t understand what I mean, go read the book :) )

Technorati Tags: , ,

written by ishaq