3 Replies Latest reply on May 6, 2011 11:16 AM by Flex harUI

    Component lifecycle: when and how is it rendered on screen?




      The short version: 1. What event is fired when everything is rendered? 2. How do I make validateNow() to actually render now?
      I am on SDK 3.5.0.




      The long version follows.


      I am using deferred creation to speed up the application startup time, which works nice. There's a complicated component which is a VBox with creationPolicy="none". Once the user clicks a "Details" button, I call addChild(theComponent) and theComponent.createComponentsFromDescriptors(true) . It takes several seconds on a fast computer, and currently, it looks as if the application does nothing during that sime. Then the component pops up. So I wanted to add some progressbar, and that's the problem.


      1. Once the user clicks, I want the progressbar to appear. I went like this:
      progbar=PopUpManager.createPopUp(manager, ProgressBar, false, null) as ProgressBar;


      then set some properties (width, label etc.). Now what I need is to wait for the progressbar to actually render, before starting the long process. How do I know it's done? I've tried component's CREATION_COMPLETE and UPDATE_COMPLETE, layoutManager's UPDATE_COMPLETE, stage's ENTER_FRAME and RENDER, also adding lots of validateNow() and callLater() but the only way I've found is to either wait for two frames, or for a RENDER then callLater. I get the feeling it's not the way it's meant to be.
      ** So, how do I know the component has been rendered? **




      2. Next, I have to addChild the big component to something existing. This already takes some time without actually being validated, so I'd like to update the progressbar. However, progbar.validateNow() doesn't update the display. Instead, Flex delves into validating the big component, taking more seconds.


      ** So, how do I cause a component to repaint immediately, without causing everything else, invisible at the time (in a  viewstack visible="false" height="0"), to be validated as well? **




      I believe the answers are simple but I just don't know the right keywords to search for; web is full of the discussions of the invalidate/validate system that actually do not explain anything; and the debugger won't let me this deep into Flex sources.




        Milan Vandrovec