Hi,

the onenterframe will work, but you can approach it a little
differently, in pseudo:

onEnterFrame {
 if (no items to process left) { clear onEnterFrame, signal done; }
 set loop start time
 while (currenttime - loop start time < 100 ms) {
   process loop item
 }
 update progressbar
}

greetz JC

On Sat, Nov 22, 2008 at 5:18 AM, jonathan howe <[EMAIL PROTECTED]> wrote:
> Yikes! I don't think he actually wants the loop to take any longer than
> necessary. I'm assuming he's got some sort of computationally expensive
> operation (huge parse or something) that he wants to show the progress. How
> about subdividing your loop into more manageable chunks that get called once
> a frame?
>
> On Fri, Nov 21, 2008 at 4:42 PM, Joel Stransky <[EMAIL PROTECTED]>wrote:
>
>> Just simulate a for loop with an ENTER_FRAME listener.
>>
>> var total:int = 10000;
>> var i:int = 0;
>> root.addEventListener(Event.ENTER_FRAME, simLoop);
>> private function simLoop(e:Event):void
>> {
>>  if(i >= total){ root.removeEventListener(Event.ENTER_FRAME, simLoop); };
>>  pbar.setProgress(i, total);
>>  i++;
>>  }
>>
>> On Fri, Nov 21, 2008 at 4:23 PM, Mac Angell <[EMAIL PROTECTED]> wrote:
>>
>> > Is it possible to show the progress of a code loop on a progress bar?
>> > For example, if I have a progress bar named "pbar" already defined on
>> > the stage, and I execute the following function:
>> >
>> >
>> >
>> > private function init():void
>> >
>> > {
>> >
>> >      var total:int = 100000;
>> >
>> >      for (var i:int = 0; i < total; i++)
>> >
>> >      {
>> >
>> >            pbar.setProgress(i, total);
>> >
>> >            stage.invalidate();
>> >
>> >      }
>> >
>> > }
>> >
>> >
>> >
>> > The progress bar jumps from 0% to 100% after a long pause (the for loop
>> > executing). I am pretty sure this happens because the entire code loop
>> > executes before the next frame gets rendered. As you can see I even
>> > tried stage.invalidate(), but my guess is that it just tells the stage
>> > to update on the next frame, instead of forcing the stage to update at
>> > that exact time.
>> >
>> >
>> >
>> > Is there any way to get this to work in AS3? In other words, is there
>> > any way to force the screen to update in the middle of a code thread?
>> >
>> >
>> >
>> > Thanks!
>> >
>> >
>> >
>> > -Mac Angell
>> >
>> >
>> >
>> > _______________________________________________
>> > Flashcoders mailing list
>> > [email protected]
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >
>>
>>
>>
>> --
>> --Joel Stransky
>> stranskydesign.com
>>  _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
>
> --
> -jonathan howe
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to