[flexcoders] Re: Help with Printing (relates to Scaling Object, just before sending printjob)

2007-12-17 Thread Todd
Could you try chaining Events?

In your function when you scale your object, can you fire off an event
when the object scaling is done.  And then in the listener for thisnew
event, fire off the Print Job?

I don't know the specifics of the PrintJob API, or what you're doing
wtih Object scaling.  But I've had to deal with a lot of image
thumbnail creation in the past and I had to create a bunch of custom
events and chain them together so I could control how the image was
loading, then the generation of the thumbnail, then the loading of the
thumbnail image, and then the adding it to a Tile.

I imagine something similar would be appropriate here.  Are jsut using
scaling properties  to change the size of your object for ptinting, or
 is there something else going on?



--- In flexcoders@yahoogroups.com, Mike Anderson [EMAIL PROTECTED] wrote:

 Greetings All!
 
 I have a major problem, where I have a function that properly scales an
 Object *just* before sending it to the printer.
 
 The issue is, the Object isn't scaling fast enough, so by the time it
 gets added to the PrintJob, it still isn't the proper scale - and looks
 completely wrong on the actual printout.
 
 Initially, I figured I could simply scale the Object first (in an
 entirely different function), then create some intentional pauses in the
 code (or use callLater in the right places), THEN run my PrintJob
 function code.  BUT, my scaling functions rely on information brought
 back from the PrintJob - like PageWidth and PageHeight - which means, my
 Scaling Function must be called from within my PrintJob function.
 
 Bottom line, is that everything is happening too quickly, for the
 PrintJob to capture the properly scaled object.
 
 Is there a way for me to insert some intentional pauses, to slow things
 down, and give the object to be printed, time to properly scale, before
 getting sent to the PrintJob?
 
 Thank you in advance, for any help you can offer.
 
 Mike





[flexcoders] Re: Help with Printing (relates to Scaling Object, just before sending printjob)

2007-12-17 Thread Randy Martin
In the code below, the event listerer function should have been:

private function finishPrint(event:CustomEvent)

Sorry, typing faster than I'm thinking.

~randy


--- In flexcoders@yahoogroups.com, Randy Martin [EMAIL PROTECTED] wrote:

 You can have a function that starts the print job, gets the page 
width and
 height, and then the last thing it does is attach an event listener 
for an
 end-of-scaling event and fires off the scaling function. The scaling
 function finishes and dispatches the end-of-scaling event, which 
runs your
 event listener function. The event listener function adds the 
scaled object
 to the print job and sends the job to the printer. Like this:
  
 private var printJob:FlexPrintJob;
  
 private function doPrint():void {
   printJob:FlexPrintJob = new FlexPrintJob();
   if (!printJob.start()) return;
   yourScalingComponent.addEventListener(scalingDone, finishPrint);
   doScaling(printJob.pageWidth, printJob.pageHeight);
 }
  
 private function doScaling(pw:Number, ph:Number):void {
   var scaleJob:MyScalingComponent = new MyScalingComponent();
   scaleJob.pageWidth = pw;
   scaleJob.pageHeight = ph;
   scaleJob.scaleIt();
 }
  
 private function finishPrint(event:scalingDone) {
   var scaledObj:ScaledObj = event.result as ScaledObj;
   printJob.addObject(scaledObj, FlexPrintJobScaleType.NONE);
   printJob.send();
  
  
 In your scaling component, define an event
  
 mx:Metadata
   [Event(name=scalingDone, type=events.CustomEvent)]
 /mx:Metadate
  
  
 Then when the scaling is complete, dispatch the scalingDone event:
  
 this.dispatchEvent(scalingDone, scaledObj); 
  
  
 The custom event looks like this (if you put it in a directory named
 events):
  
 package events {
   import flash.events.Event;
  
   public class CustomEvent extends Event {
 public var myObj:Object = null;
   
 public function CustomEvent(type:String, obj:Object) {
   super(type, true, true);
   this.myObj = obj;
 }
   }
 }
  
  
 HTH,
 ~randy
  
 
  
 
_  
 
 From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
 Behalf Of Mike Anderson
 Sent: Monday, December 17, 2007 12:12 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Help with Printing (relates to Scaling 
Object, just
 before sending printjob)
 
 
 
 
 Greetings All!
 
 I have a major problem, where I have a function that properly 
scales an
 Object *just* before sending it to the printer.
 
 The issue is, the Object isn't scaling fast enough, so by the time 
it
 gets added to the PrintJob, it still isn't the proper scale - and 
looks
 completely wrong on the actual printout.
 
 Initially, I figured I could simply scale the Object first (in an
 entirely different function), then create some intentional pauses 
in the
 code (or use callLater in the right places), THEN run my PrintJob
 function code. BUT, my scaling functions rely on information brought
 back from the PrintJob - like PageWidth and PageHeight - which 
means, my
 Scaling Function must be called from within my PrintJob function.
 
 Bottom line, is that everything is happening too quickly, for the
 PrintJob to capture the properly scaled object.
 
 Is there a way for me to insert some intentional pauses, to slow 
things
 down, and give the object to be printed, time to properly scale, 
before
 getting sent to the PrintJob?
 
 Thank you in advance, for any help you can offer.
 
 Mike
 
 
  
 
 
 No virus found in this outgoing message.
 Checked by AVG. 
 Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date: 
12/16/2007
 11:36 AM