Ashine
Ashine

Reputation: 4717

Is there some way to force 'updatedisplaylist' immediately rather than at later some point

In flex component life cycle, after we make some change in a components property, invalidation methods schedules a call to methods like commitProperties, updateDisplayList, etc for some later time. I need to call the updateDisplayList instantaneously. Is there some direct way to do this. Currently, both the labels are changed simultaneously after completion of the loop. Instead I need it to work like this, to first render the updated 'myButton1' label then enter the loop and then update myButton2's label. I know, it is elastic race track issue, but isn't there some way to achieve this ?

myButton1.label = 'New Label1' ;
// Some logic to forcibly make the screen reflect it

for (var i:int = 0; i < 500 ; i ++){
//a dummy loop

}

myButton2.label = 'New Label2' ;

Upvotes: 0

Views: 2670

Answers (4)

anand
anand

Reputation: 33

invalidateDisplayList() or valdiateNow() will do it for you however excess of using these will end up memory leaks.

Upvotes: 0

Wade Mueller
Wade Mueller

Reputation: 6059

I would set the label for myButton1, then put the remaining code into a separate method and call that method using callLater:

private function foo():void {
    myButton1.label = 'New Label1';
    this.callLater(bar);
}

private function bar():void {
    for (var i:int = 0; i < 500 ; i ++){ //a dummy loop
    }
    myButton2.label = 'New Label2';
}

This way myButton1 will update to show the new label before going into your loop since callLater doesn't call bar until after the event queue is cleared, giving myButton1 a chance to update.

Upvotes: 1

JeffryHouser
JeffryHouser

Reputation: 39408

Use validateNow() . But, I would use it sparingly. using invalidateDisplayList() will force updateDisplayList() to run on the next renderer event.

A render event happens on each frame. 24 frames happen each second by default for Flex. Are you sure need to change these values quicker?

Upvotes: 2

sharvey
sharvey

Reputation: 8145

You can use myButton1.validateNow() but it's use is discouraged, for you may end up having the same component update itself multiple times on the same frame.

Upvotes: 2

Related Questions