6 Replies Latest reply on Aug 18, 2008 9:57 PM by mavdzee

    Incrementaly display VBox: limitation in Flex?

    mavdzee
      Hi,

      I posted this question before without usable answers what makes me thinks that this is one of Flex 3 limitations. I have a VBox and want to add up to 150 charts (maybe even more later) as its children. What happens is that Flash calculates all the charts and then displays them all at ones. This takes about 20 seconds. Therefor I would like to build the VBox incrementally and redraw the VBox after each chart has been added. For the purpose of illustration here some sample code:

      var profileTab:ProfileTab = new ProfileTab();
      for each (var data:XML in allData)
      {
      var chart:ProfileConfigChart = new ProfileConfigChart();
      profileTab.addChild(chart);
      chart.init(data);
      // Here I would like to force a redraw. Impossible?
      }

      I tried many things among the following:
      * Recursively add each chart in a callback-method in callLater()
      * Dispatch an event when ProfileConfigChart is addedToStage and implement a listener to add the next chart
      * profileTab.invalidateDisplayList() and other invalidateXXX()

      Did I find a limitation in Flex?

      Cheers,
      Andrej




        • 1. Re: Incrementaly display VBox: limitation in Flex?
          wyattbiker Level 1
          i guess you are looking for some sort of a DoEvents like in VB. I havent tried it but this thread may be of help

          http://www.actionscript.org/forums/showthread.php3?t=41256
          • 2. Re: Incrementaly display VBox: limitation in Flex?
            mavdzee Level 1
            Thanks for your answer, but I have tried to "pause" CPU calculation to enable Flash to display the VBox by means of adding each chart in an invocation of callLater() and also by adding the next chart after receiving a addedToStage event. None of this helps. Any comments from the Adobe-guys would help, instead of the "silent-treatment".
            • 3. Re: Incrementaly display VBox: limitation in Flex?
              g-s-b Level 1
              I do similar things.
              The for loop is not it : you need a 'timed' loop, like onEnterFrame or a simple timer.

              What I do is add 4-5 graphs and set up a loop based on the frame update to add one for each of the next n frames. In that loop, you can use invalidate (prob not needed in your scheme) to insure that the VBox is updated:
              invalidateDisplayList()

              • 4. Re: Incrementaly display VBox: limitation in Flex?
                ntsiii Level 3
                One way is to have an "iterator" function that actually draws the chart.

                Have an instance variable that holds the current iteration index. (also will need an end index) In your chart iterator, use the iterator index to find the data in the XMLList, then draw the chart. Have it call a second function, using callLater(), which checks the iteration against the end index and conditionally calls the chart iterator function.

                Tracy
                • 5. Re: Incrementaly display VBox: limitation in Flex?
                  mavdzee Level 1
                  The callLater() approach does not work, as I said before.

                  The Timer-approach does work. It seems like a workable solution, the only problem is to estimate the Timer-interval. If the Timer-interval is smaller than it takes to calculate the chart, Flash is not given the time to update the screen and it does does work. In my case it is difficult to estimate the calculation-time, since it depends on the size of the XML passed into the chart.

                  Therefor a cleaner approach would be to add the next chart as the previous chart is is actually DRAWN on the screen. I though I could use the event addedToStage for the chart, but this event seems to be triggered when it is added to the display list only. Is there a similar event that is triggered after a component is actually DRAWN on the screen?

                  Thanks for your workaround!

                  Cheers,
                  Andrej
                  • 6. Re: Incrementaly display VBox: limitation in Flex?
                    mavdzee Level 1
                    Okay, I found the event "updateComplete" which it triggered after it is completely drawn on the screen. That's what I needed!

                    Cheers,
                    Andrej