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 [email protected], "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: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Mike Anderson > Sent: Monday, December 17, 2007 12:12 PM > To: [email protected] > 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 >

