Unfortunately, same problem with callLater in either pattern.

I was able to solve my issue though, and I did so like this:

-I created my own simple custom component.
-It has one property "percentComplete", when this property is set it updates 
the property and calls "invalidateDisplayList()".
-It ovverides updateDisplayList and uses the drawing API to draw a progress bar 
there based on percentComplete. And at the end of updateDisplayList It calls 
dispatchEvent.
-In my code, instead of listening for a timer, I listen for that event on my 
custom progress bar. Every time I hear the event, I addChild and update the 
percentComplete.

This works perfectly. Listening for ENTER_FRAME, EXIT_FRAME, RENDER, etc did 
not work, so I had to add the custom event.

-Christopher



-----Original Message-----
From: flexcoders@yahoogroups.com on behalf of Peeyush Tuli
Sent: Thu 3/4/2010 5:27 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Trouble with ProgressBar and manual updates.
 
what happens when you go the other way around... meaning that the add is
done before and progress bar update is sent to calllater?

On Wed, Mar 3, 2010 at 11:56 PM, Christopher McArthur <
cmcart...@riotgames.com> wrote:

>
>
>  callLater is a great suggestion, thank you. Unfortunately, was not
> helpful in this case. Even delaying the adds by a callLater does not allow
> the progressBar to update visually.
>
>
>
> *From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On
> Behalf Of *Peeyush Tuli
> *Sent:* Tuesday, March 02, 2010 10:18 PM
> *To:* flexcoders@yahoogroups.com
> *Subject:* Re: [flexcoders] Trouble with ProgressBar and manual updates.
>
>
>
>
>
> it might be that all the processing is too much to be displayed in the same
> frame. So this might help you
>
> http://jimmyflex.blogspot.com/2007/11/dont-forget-power-of-calllater.html
>
>
> ~Peeyush
> http://www.mds.asia
>
> http://jimmyflex.blogspot.com/2007/11/dont-forget-power-of-calllater.html
>
>  On Wed, Mar 3, 2010 at 6:53 AM, Christopher McArthur <
> cmcart...@riotgames.com> wrote:
>
>
>
> Using Flex3 in AIR standalone application.
>
>
>
> I have a ton of children I need to add to a Canvas dynamically. When I do
> this, it takes a long time. So I wanted to display a loading bar to the
> user.
>
>
>
> I create a Timer, and every time the timer ticks, I update the loadingBar
> and I add the child. I also update a textField with the loading progress as
> a debug tool.
>
>
>
> What I find is that the textField _always_ updates correctly in realtime,
> but USUALLY the progress bar does NOT update at all until the entire
> sequence is finished. If I make the tick time long enough, then the progress
> bar works, but this time seems very dependent on performance of the
> individual machine.
>
>
>
> My question is, how do I know what the lowest possible tick time I can use
> to make the progress bar update correctly is? Why does it work with the Text
> field just fine? Or is there a better pattern I could be using to do this
> correctly?
>
>
>
> As you can see from the code, I tried some things like "updateAfterEvent"
> and "invalidateDisplayList" to see if I could get it to update faster, but
> those did not work (unless I set the tick time high).
>
>
>
> code here:
>
>
>
> *private* *var* pendingElementsToAdd:Array;
>
> *private* *var* totalElementstoAdd:int;
>
> *private* *static* *const* TIME_BETWEEN_ADDS:Number = 20;
>
>
>
>
>
> *private* *function* addElements(newElements:Array):*void*
>
> {
>
> *      this*.pendingElementsToAdd = newElements;
>
>       *this*.totalElementstoAdd = *this*.pendingElementsToAdd.length;
>
>       var newEventTimer:Timer = *new* Timer(TIME_BETWEEN_ADDS,
> newElements.length);
>
>       newEventTimer.addEventListener(TimerEvent.TIMER,
> onTimerAddNewElement);
>
>       newEventTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
> finishAddingElements);
>
>       newEventTimer.start();
>
> }
>
>
>
> *private* *function* onTimerAddNewElement(event:TimerEvent):*void*
>
> {
>
>                   *this*.loadingBar.setProgress(*this*.totalElementstoAdd
> - *this*.pendingElementsToAdd.length, *this*.totalElementstoAdd);
>
>                   *this*.loadingText.text = *"Elements To Load: "* + *this
> *.pendingElementsToAdd.length;
>
>
>
>                   event.updateAfterEvent();
>
>                   *this*.loadingBar.invalidateDisplayList();
>
>
>
>                   *this*.addChild(*this*.pendingElementsToAdd.pop());
>
> }
>
>   
>


Reply via email to