I have a process that takes long to execute, I want to be
able to send a progress notification to the user with the hope of
not getting him bored or impatient, for some reason I can't achieve
it and I don't know where to go for help, if you know how to solve
this, any help will be greatly appreciated.
I have some code like this:
<code in mxml for my application>
- component declared .. onXEvent="showProgress()"
- script for showProgress calls refresh for ProgressBar
</code in mxml for my application>
. . .
<code for my component>
for each (var myObject:xObject in MyCollectionOfMyObjects)
// do some complex logic and calls methods for this item
// creates and triggers event for progress notification
</code for my component>
I would expect to see my ProgressBar advancing as the process
is completed, but for some reason the process seems to take control
of the execution and no onProgressEvent is fired until the foreach
finishes execution. It will run perfectly in the debugger (step by
step) but it doesn't work at runtime.
Is there any way I can achieve this in Flex?? Is there any
event class I can use to solve this issue?
maybe anyone has done this before or knows a link to more
information on this subject?
Flash functions execute within a frame. They finish before
any UI rendering is done. You will have to use callLater , somehow,
within your loop to give the UI a chance to draw.. There is a more
detailed answer to this thread somewhere else.