From a actionscript function in flex, how do I get the UI to update like it would if I called DoEvents in VB?

I have a function in my flex app that produces a pdf.   Producing the pdf can take a few seconds, I'd like to display a popup for the user to let them know they need to wait, so at the top of my function I use CursorManager and PopUpManager to inform the user, but the dialog is never displayed because control never passes back to the ui.

In VB, this problem is easily worked around by a call to "DoEvents".

How do I work around this problem in actionscript?
CursorManager.setBusyCursor()
dlgPleaseWait = PopUpManager.createPopUp(this, PleaseWait, true) as PleaseWait;
PopUpManager.centerPopUp(dlgPleaseWait);

Open in new window

DrachsAsked:
Who is Participating?
 
Gary BenadeConnect With a Mentor Commented:
function makePDF( fn:String):void
{
  makePDF();   // do the hard work here
  PopUpManager.removePopUp(dlgPleaseWait);
  CursorManager.removeBusyCursor()
}


function onClick():void
{
  CursorManager.setBusyCursor()
  dlgPleaseWait = PopUpManager.createPopUp(this, PleaseWait, true) as PleaseWait;
  PopUpManager.centerPopUp(dlgPleaseWait);
  callLater( makePDF,['mypdf.pdf']);   // this function will cause makePDF to be called in the next 'frame' after UI update
}
0
 
DrachsAuthor Commented:
Sorry it took me so long to accept this solution, and thanks for taking the time to provide it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.