Flex 中的低开销动态选项卡/ViewStack?
假设我有一个像这样的 ViewStack:
<mx:ViewStack id="s" left="5" right="5" bottom="5" top="0" width="100%" height="100%" creationPolicy="all" minHeight="0">
<mx:Repeater id="repeater" dataProvider="{dp}" height="100%" width="100%" minHeight="0">
<mx:Box id="bx" label="{repeater.currentItem.label}" width="100%" height="100%" minHeight="0">
<mx:Label minHeight="0" width="100%" height="100%" label="bob" />
</mx:Box>
</mx:Repeater>
</mx:ViewStack>
堆栈中有大量项目(每个项目都有大量面板、数据绑定等),这会变得非常慢。无论 viewStack 本身的创建策略如何,Repeater 似乎都会触发所有子级的创建。
对于这个效率问题有现成的解决方案吗?我可以想出一些方法来使用自定义组件来解决它,但我想知道对于内部值确实需要像这样动态(由 ArrayCollection 支持)的情况是否有现成的解决方案。
Suppose I have a ViewStack like this:
<mx:ViewStack id="s" left="5" right="5" bottom="5" top="0" width="100%" height="100%" creationPolicy="all" minHeight="0">
<mx:Repeater id="repeater" dataProvider="{dp}" height="100%" width="100%" minHeight="0">
<mx:Box id="bx" label="{repeater.currentItem.label}" width="100%" height="100%" minHeight="0">
<mx:Label minHeight="0" width="100%" height="100%" label="bob" />
</mx:Box>
</mx:Repeater>
</mx:ViewStack>
With a large number of items in the stack (each having a large number of panels, databinding, etc), this gets extremely slow. The Repeater seems to trigger creation of all children regardless of the creationPolicy of the viewStack itself.
Is there a readymade solution to this efficiency problem? I can think of some ways to solve it with a custom component, but I'm wondering if there's an off the shelf solution for cases where the inner values really need to be dynamic (backed by an ArrayCollection) like this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设除了其中显示的一些特定数据之外,所有堆叠视图都是相同的,可能的解决方案是放弃视图堆栈并将所有控件设置为绑定到数组集合,那么您将使用任何控件来更改视图堆栈更新您的数组集合。
Assuming that all your stacked views are identical except for some specific data displayed in them a possible solution would be to ditch the viewstack and set up all your controls to bind to an array collection, then whatever control you would use to change your viewstack could instead update your array collection.
尝试将 List 与 itemRenderer 一起使用。中继器因糟糕的性能而臭名昭著。
Trying using a List with an itemRenderer. Repeaters are notorious for terrible performance.