2 Replies Latest reply on May 19, 2008 6:10 PM by ntsiii

    Show the progress of an action script function

      Sorry for my English :-(

      I have a very long action script function, updating a database, and I want to show their progress on screen with a component Progress Bar.

      I am using a Progress Bar in mode=manual and a function like this:

      private function longfunction() : void {
      <bla,bla, bla>
      pg.setProgress(10, 100);
      pg.label= "Loading 10%";
      <bla,bla, bla>
      pg.setProgress(50, 100);
      pg.label= "Loading 50%";
      <bla,bla, bla>
      pg.setProgress(100, 100);
      pg.label= "Loading 100%";

      But the progress bar not refresh in screen until ends the function. ¿Why? How I can force refresh screen in each progress?
        • 1. Re: Show the progress of an action script function
          javamonjoe Level 1
          You might try checking the mode of update defined for your progressBar. The default mode is Event and you are using Manual. You do not need to be concerned with your English. It is miles above my Spanish!
          • 2. Re: Show the progress of an action script function
            ntsiii Level 3
            The Flash Player is essentially single threaded. The UI will not update until the processing in the current frame is complete.

            The only way to work around this is to break the processing up into parts. Between the parts, use callLater() to allow the UI a chance to update.

            You can maintain a counter variable outside your function. Have your function start at the counter variable, and loop for some number of iterations(100?), update the counter, then call itself again, using callLater().