Flex:渲染绑定的 TileList - 什么时候完成渲染?

发布于 2024-09-01 08:29:06 字数 567 浏览 9 评论 0原文

我有一个绑定到 ArrayCollection 的 mx:TileList。我有一些代码在修改 ArracyCollection 之前显示“正在加载...”消息,而之后的一些代码则隐藏加载消息。

对于小数据集,它工作得很好。然而,我注意到,当数组大小约为 50~ 或更大时,flex 会在 TileList 完成渲染新数据之前隐藏我的加载消息,并且我会在奇数秒内留下空白屏幕。

是否有一个我可以监听 TileList 完成重新渲染后调用的事件?代码如下所示:

loading_message.visible = true;
for each (var x:Object in new_data) {
    tile_list_data.append(x); // bound to my_tile_list component
}
my_tile_list.validateNow();
loading_message.visible = false;

在本示例中,loading_message 出现、消失,然后 Flex 应用程序将滞后,然后最终显示更新的 TileList。

有什么想法吗?谢谢!

I have an mx:TileList which is bound to an ArrayCollection. I have some code that displays a "Loading..." message before modifying the ArracyCollection and some code after that hides the loading message.

For small data sets, it works fine. However, I noticed with an array size of about 50~ and larger, flex will hide my loading message before the TileList is finished rendering the new data and I'm left with a blank screen for an odd second.

Is there an event I can listen to that is called after the TileList is finished re-rendering? Code looks something like this:

loading_message.visible = true;
for each (var x:Object in new_data) {
    tile_list_data.append(x); // bound to my_tile_list component
}
my_tile_list.validateNow();
loading_message.visible = false;

In this example, loading_message appear, disappear, and then the flex app will lag before finally revealing the updated TileList.

Any ideas? Thanks!

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

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

发布评论

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

评论(1

最佳男配角 2024-09-08 08:29:06

问题是,它没有执行 .visible=true,运行 foreach 循环并等待它完成,然后转到 .visible=false,但实际上运行 .visible,对于每个,.visible 。

如果您想确保 foreach 在下一个代码行继续之前结束,您需要将其余代码移动到另一个函数,该函数将由某些 您将创建的自定义事件

现在,在每个 for 中,您需要添加一个代码来检查它是否已完成,然后调用您的自定义事件调度程序。

var n:Number = 0;
for each (var x:Object in new_data) {
    ++n;
    tile_list_data.append(x); // bound to my_tile_list component
    if (new_data.length <= n) { call the event }
}

因此,现在您将拥有一些自定义事件调度程序,该调度程序将调用另一个包含代码其余部分的函数,包括 .visable=false.,确保代码的其余部分仅在 foreach 之后运行结束。

我知道这很丑陋,但这是我能想到的确保它有效的唯一方法。

The problem is, that it doesn't do the .visible=true, run the for each loop and waits until it is done, and then goes to the .visible=false, but actually runs the .visible, for each, .visible.

If you want to make sure that your for each ends before the next code line continues, you'll need to move the rest of the code to another function, that will be called by some custom event you'll make.

Now, inside your for each you'll need to add a code that checks if it's done, and then call your custom event dispatcher.

var n:Number = 0;
for each (var x:Object in new_data) {
    ++n;
    tile_list_data.append(x); // bound to my_tile_list component
    if (new_data.length <= n) { call the event }
}

So now you'll have your for each with some custom event dispatcher that will call another function that contains the rest of your code, including the .visable=false., making sure that the rest of your code will run only after the for each ends.

I know it's ugly, but that's the only way I can think of to make sure it'll work.

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