Yeah, your problem is not the synchronous nature of the operation or the
activity indicator, that can be done as you have tried, or with callLater.
Your problem is that you want the save operation to happen automatically
when the processing is done, and are getting the security problem.

 

You could pop-up a "do you want to save" dialog and invoke the save from
there.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: [email protected] [mailto:[email protected]] On
Behalf Of jamesfin
Sent: Wednesday, November 18, 2009 5:27 PM
To: [email protected]
Subject: [SPAM] [flexcoders] Re: Progress for synchronous operation

 

  

It depends on what you want to display. If you put up some kind of progress
or other status UI then immediately jump into your sync. operation, it's
unlikely the status UI will have been rendered by the time you entered it.
No different than an infinite loop in the flash player.

A couple of ideas...that I've cooked up before.

1. Break up your sync. operation by using a timer or enter frame

2. Put up a "Please Wait" UI and when that is visible, fire off a timer to
do your sync. work.

A reminder that Flex is event driven so if you don't let events fly, nothing
will fly.

I'm sure there are other options but I run across these often.

--- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com,
Richard Rodseth <rrods...@...> wrote:
>
> I'm really stumped by this. Is there *any* way I can display a busy during
> a long-running *synchronous* operation?
> 
> On Mon, Nov 16, 2009 at 10:29 AM, Richard Rodseth <rrods...@...>wrote:
> 
> > Can anyone suggest a solution?
> >
> >
> > On Wed, Nov 11, 2009 at 3:23 PM, Richard Rodseth <rrods...@...>wrote:
> >
> >> So I tried this pattern:
> >>
> >> private function onClickSave(event:Event):void {
> >>
> >> CursorManager.setBusyCursor();
> >> var generatePDF:Function = function(e:Event):void {
> >> ....
> >> savePDF(bytes);
> >> };
> >>
> >> // Delay start so cursor can display
> >> var timer:Timer = new Timer(1, 1);
> >> timer.addEventListener(TimerEvent.TIMER, generatePDF);
> >> timer.start();
> >> }
> >>
> >> private function savePDF(pdfBinary:ByteArray):void {
> >> var fileRef:FileReference = new FileReference();
> >> fileRef.save(pdfBinary,"MyReport.pdf");
> >> }
> >>
> >> But then of course I get the security error below from savePDF:
> >>
> >> Error: Error #2176: Certain actions, such as those that display a
pop-up
> >> window, may only be invoked upon user interaction, for example by a
mouse
> >> click or button press.
> >> at flash.net::FileReference/_save()
> >>
> >> Any good ideas for displaying a busy cursor or indeterminate progress
bar
> >> while doing a long-running synchronous operation?
> >>
> >>
> >> On Wed, Nov 11, 2009 at 9:59 AM, Richard Rodseth <rrods...@...>wrote:
> >>
> >>> Thanks. Yes, I wasn't expecting to show dynamically-updating progress
> >>> during the synchronous operation. Just wanted to pop up something (or
change
> >>> the cursor) before, and remove it after. I'll take a closer look at
the
> >>> AlivePDF docs.
> >>>
> >>>
> >>> On Wed, Nov 11, 2009 at 6:24 AM, ag_rcuren <robert.vancuren...@...
> >>> > wrote:
> >>>
> >>>>
> >>>>
> >>>> I am not fully sure how AlivePDF works because I have never used it
but
> >>>> I thought that it could be done asynchronously because I saw a
complete
> >>>> event in the documentation that reads:
> >>>> "Dispatched when PDF has been generated and available. The save()
method
> >>>> generate this event"
> >>>>
> >>>> That to me says that it can be generated asynchronously but like I
said
> >>>> I really dont know.
> >>>>
> >>>> As far as showing progress during a synchronous call it is not
possible.
> >>>> This is because the synchronous call does not return until it is done
and
> >>>> thus the UI will never get a chance to update during the process.
> >>>>
> >>>> If you want to show something before that is possible. You could use
a
> >>>> timer or you may want to look at the callLater method of
displayObject as
> >>>> this will wait one frame before calling the method you want. This
would
> >>>> allow you to show say a pop up or something so they user could at
least see
> >>>> something.
> >>>>
> >>>>
> >>>> --- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com>
ups.com <flexcoders%40yahoogroups.com>,
> >>>> Richard Rodseth <rrodseth@> 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?
> >>>> >
> >>>>
> >>>> 
> >>>>
> >>>
> >>>
> >>
> >
>



Reply via email to