何时(从生命周期角度)为 Flex 3 上的 LIST 容器设置数据提供者是正确的时间点
我正在使用自己的项目渲染器创建一个 LIST 容器来显示 xml 文件。
现在,我正在重写项目渲染器中的 public override function set data(value:Object):void 方法,问题是该函数被调用了很多次(!!)(比数据提供者长度)。
也许我没有正确设置数据提供程序,这是我的做法:
首先声明可绑定属性:
[Bindable]
private var _listDataProvider:XMLListCollection;
然后,创建 LIST 对象:
<mx:List id="list" dataProvider="{_listDataProvider}" itemRenderer="myItemRenderer" />
然后,加载 xml(使用 urlLoader)并在结果中执行:
_listDataProvider = new XMLListCollection(xml..Person);
XMLListCollection 构建正常(我可以在调试中看到它)。
我做错了什么????
谢谢各位...
I'm making a LIST container with my own item renderer to display xml file.
Now, I'm overriding the public override function set data(value:Object):void
method in my item renderer, the problem is that this function been called many times(!!) (more then the data provider length).
Maybe I'm not setting the data provider right, here is how I do it:
First declare bindable property:
[Bindable]
private var _listDataProvider:XMLListCollection;
Then, creating LIST object:
<mx:List id="list" dataProvider="{_listDataProvider}" itemRenderer="myItemRenderer" />
Then, loading the xml (with urlLoader) and in the result doing:
_listDataProvider = new XMLListCollection(xml..Person);
The XMLListCollection build-up ok (I can see it in debug).
What am I doing wrong?????
Thanks guys...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,这是正确的,我有一种感觉,Flex 3 List 和相关的 dataProvider 组件将在第一轮中为每个项目渲染器设置几次数据(框架效率低下)。第一次,他们可能会将其设置为 null(会发生这种情况吗?),然后下次他们可能会将其设置为该值。
要解决这个问题,只需执行以下操作:
这应该可以解决问题。
It looks right to me, I have a feeling the Flex 3 List and related dataProvider components will set the data a few times for each item renderer the first round (inefficiencies in the framework). The first time, they might set it to null (is that happening?), then the next time they might set it to the value.
To get around this, just do something like:
That should do the trick.