Thanks for all the suggestions. Some won't work because of the security issue, since at the end I need to do a FileReference.save and that must come direct from a click.
However if I pop up a window that says "Generating PDF" and *it* has a Save button, that could perhaps work. But so far, playing around with "add" "creationComplete" and "show", I haven't found a way to detect that the the popup window is displayed, so I can begin the image encoding (which is actually what's taking the time). Any good way to know that a popup is displayed? As an experiment, I put a "Generate" button in the popup as well, and as soon as I clicked it, the indeterminate progress bar stopped animating, so I guess my dialog will just have to say "This may take a while. Wait for the Save button to be enabled". On Wed, Nov 18, 2009 at 5:09 PM, Johannes Nel <[email protected]>wrote: > > > well if it is synchronous then this will help squat unless a separate > thread gets spawned, since the drawing cycle and the render cycle are split > in the vm. so, if it does not lock up the vm (which basically renders you > powerless) then it ain't synchronous. > > > On Thu, Nov 19, 2009 at 2:57 AM, ag_rcuren > <[email protected]>wrote: > >> >> >> Here is some code that will show a very simply way using a timer to show >> some UI before you start your sync stuff. NOTE using a timer is bad because >> you can not guarantee how much time it will take for your UI to display. The >> best thing to do would be create some sort of popup that fires an event when >> it is fully visible. Listen for that even and once that happens then you >> start your synchronous process because at that time you will be sure your UI >> is ready. >> >> <?xml version="1.0" encoding="utf-8"?> >> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >> layout="absolute"> >> <mx:Script> >> <![CDATA[ >> import mx.managers.CursorManager; >> import mx.events.FlexEvent; >> import mx.controls.Alert; >> >> private function bigNastySynchronousThing():void >> { >> trace("running"); >> var i:int = 0; >> for (i; i < 20000000; i++) >> { >> //trace really slows things down >> var x:Number = Math.sqrt(500) / Math.sqrt(20); >> } >> trace("done"); >> } >> >> private function noGood(event:MouseEvent):void >> { >> mx.controls.Alert.show("You wont see this untill we are done because the >> ui cant update"); >> bigNastySynchronousThing(); >> } >> >> private function kindGood(event:MouseEvent):void >> { >> Alert.show("This will take some time, hold on"); >> CursorManager.setBusyCursor(); >> var t:Timer = new Timer(1000, 1); >> t.addEventListener(TimerEvent.TIMER_COMPLETE, tc); >> t.start(); >> } >> >> private function tc(event:TimerEvent):void >> { >> trace(event.target); >> EventDispatcher(event.target).removeEventListener(event.type, >> arguments.callee); >> this.callLater(bigNastySynchronousThing); >> CursorManager.removeBusyCursor(); >> >> } >> ]]> >> </mx:Script> >> <mx:Button label="no good" click="noGood(event);"/> >> <mx:Button label="kinda good" click="kindGood(event);" x="81"/> >> </mx:Application> >> >> >> --- In [email protected] <flexcoders%40yahoogroups.com>, Richard >> Rodseth <rrods...@...> wrote: >> > >> > What's a good way to display progress or a busy cursor for a potentially >> > long-running, but synchronous operation (in my case generating a PDF >> using >> > AlivePDF) ? >> > >> > As noted here, CursorManager.setBusyCursor doesn't display the cursor >> until >> > there is no code running, and PopupManager seems to act similarly. >> > >> > Defer initiation of the operation using a timer? >> > >> >> > > > -- > j:pn > \\no comment > >

