Set the progress bar not to be indeterminant, then generate progress events from your buildUI as it builds. Or set things up so the entire UI doesn't have to build before you can show something.
I'd agree with Amy, generate a some kind of progress events as you traverse through the UI build, events and their handling are async. Im not sure this means threads, but it sure acts that way!
Messing around with the visual innards of Flex is my weak point ( one amongst many ). But
This seems a little sketchy. The UI components in Flex have deferred instantian meaning that they are created when they are needed. This allows for faster startup time and avoidance and better performance of UI components. I assume that when you have the buildUI() function, you are in a way bypassing some of the benefits provided by the framework in terms of component lifecycle and deferred creation of objects. Your buildUI thread is going to block,I assume, meaning that not too much else is going to happen until it is done which is probably why your UI appears to freeze.
>...My idea: The MyComponent should be created in a thred which would not block the main movie. But, Flex obviously does not know of Threads.
The flashplayer as of now is single threaded, they have a multi-threaded one in the next release I believe but I am not sure of the specifics. I don't know of how much of a help it would be because you have to understand the flashplayer component lifecycyle AND concurrency.
1 person found this helpful
I understand the problem, since I've faced it also. Remember, threads don't get you more compute power. In fact, if there are several compute-bound threads, it will actually finish slower than a single thread, because of thread-switching overhead.
No threads yet in Flex, but if you are using HTTP requests, the I/O event hander runs in a lightweight thread context. Overlapping I/O and graphic activities can result in better performance.
I like using a sequence of adding children, so that the user sees that things are happening. Much more satisfying than a progress bar.
If you are using Flex Builder 4.5 Pro - you can analyze for performance bottlenecks. You can even get a trial version for a month - maybe that would be enough time to speed things up. I was able to get a factor of TEN speedup by analyzing the bottlenecks and optimizing only them. I use many many custom components which extend BorderContainer, and I get good performance. But when I had hundreds of these custom components created at start time - it was slow.
Do the performance analysis, and then fix the slow spots. You'll be surprised where you are spending your compute time.