Title: Message
Example in case you miss it:
 
 
Think of doLater as "next screen refresh".
 
What it is best used for is ensuring that GUI updating methods only run once per frame since you can only update the GUI once per frame.  Think of the term "frame" as "time to refresh the screen".  Each frame tick is a guarenteed time that the screen will refresh.
 
On thing doLater doesn't do, however, is ensure the same method isn't called more than once.  That is why finer grained methods like invalidate, invalidateLayout, etc. better because you can call them 50 times, and they'll only refresh the screen once next frame.
 
So this:
 
invalidateLayout();
 
is better than this:
 
doLater(myComponent, "invalidateLayout");
doLater(myComponent, "invalidateLayout");
doLater(myComponent, "invalidateLayout");
 
Since the latter calls the same function 3 times.
 
Now, for your purposes, your're just trying to get a ProgressBar to show an update of an insanely intense process.  Gordon's got the tried and true way of solving that; the number option he talks about is awesome because it allows you to throttle it down for your lowest target platforms.
 
Here is an example:
 
 
Keep in mind, this won't work for every scenario.  If your insistent that you force a 1000 sized recordset down Flex throat vs. paging, that's still a huge arse RS you'll have to float around... but at least you can see how you can spread out your functions who don't pass unit testing time trials/profiling.
 
----- Original Message -----
Sent: Wednesday, May 04, 2005 9:56 PM
Subject: RE: [flexcoders] Force UI update during intense AS work: doLater, maybe?

Thanks, yes, I do get the idea.  I would have though that putting the doLater on my recursive call would have done the trick.  I�ll try again, maybe I just gave up too soon.

 

Tracy

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Gordon Smith
Sent: Wednesday, May 04, 2005 9:02 PM
To: '[email protected]'
Subject: RE: [flexcoders] Force UI update during intense AS work: doLater, maybe?

 

The Flash player won't update the screen while one of your methods is executing. You'll have to break your work up into chunks which can execute over a sequence of frames. A typical way to do this is:

 

1. Define an object which will keep track of how far your work has progressed. For example, it might store that you have processed 50 tree nodes.

 

2. Write a method which will incrementally do more work. For example, it might 10 more tree nodes starting from where you left off the last time it was invoked.

 

3. Have this method doLater() itself if it doesn't finish the job.

 

I'm sorry thatI don't have any code to share that illustrates this technique, but I hope you get the idea.

 

- Gordon

 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 04, 2005 5:06 PM
To: [email protected]
Subject: [flexcoders] Force UI update during intense AS work: doLater, maybe?

One part of our app does VERY intense work, building a tree, an inverted tree (thousands of nodes), and several arrays.  Even though I have a progress bar, and update it and its label throughout the various function calls, those updates never appear on the screen, until that particular processing ends and we go to get more data.

I have fiddled with using doLater between the recursive function calls, but did not have any success forcing the screen to repaint.

Is doLater the right idea?  Do I put my screen update code before the doLater? After? How can I tell the processing to take a breath and let the UI render?

Tracy

 



Yahoo! Groups Links

Reply via email to