有没有办法强制“updatedisplaylist”?立即而不是稍后某个时刻

发布于 2024-09-09 03:29:57 字数 487 浏览 4 评论 0原文

在 Flex 组件生命周期中,当我们对组件属性进行一些更改后,失效方法会安排稍后调用 commitPropertiesupdateDisplayList 等方法。我需要立即调用 updateDisplayList 。有没有一些直接的方法可以做到这一点。 目前,两个标签在循环完成后同时更改。相反,我需要它像这样工作,首先渲染更新的“myButton1”标签,然后进入循环,然后更新 myButton2 的标签。我知道,这是弹性赛道问题,但没有什么方法可以实现这一点吗?

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' ;

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' ;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

沉默的熊 2024-09-16 03:29:57

您可以使用 myButton1.validateNow() ,但不鼓励使用它,因为您最终可能会在同一帧上多次更新同一组件。

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.

不气馁 2024-09-16 03:29:57

使用 validateNow() 。但是,我会谨慎使用它。使用 invalidateDisplayList() 将强制 updateDisplayList() 在下一个渲染器事件上运行。

渲染事件发生在每一帧上。 Flex 默认情况下每秒发生 24 帧。您确定需要更快地更改这些值吗?

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?

蘑菇王子 2024-09-16 03:29:57

我会为 myButton1 设置标签,然后将剩余的代码放入一个单独的方法中,并使用 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';
}

这样 myButton1 将在进入循环之前更新以显示新标签,因为 callLater 在事件发生后才会调用 bar队列被清除,为 myButton1 提供更新的机会。

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.

流星番茄 2024-09-16 03:29:57

invalidateDisplayList() 或 valdiateNow() 会为您完成此操作,但是过度使用这些将最终导致内存泄漏。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文