Flex/AS3 多状态项目渲染器问题
我创建了一个具有 3 种状态的模块作为 itemrenderer。这些状态称为电影、歌曲和电视节目。基本状态为空。 itemRenderer 由 Hbox、Vbox 和标签组成。
我创建了一个列表组件。
我想要做的是填充列表组件中的数据并使用我的 ItemRenderer 使其可见。根据从数据库中提取的数据,我想显示 itemRenderer 的正确状态。因此,如果从数据库中提取的记录是一首歌曲,我想显示歌曲状态,如果是一部电影,我想显示电影状态等等。
因此,根据提取的数据,我想更改 itemrenderer 的当前状态。我该怎么做? 有人可以给我举个例子,我将如何编写这段代码吗?
谢谢
I have created a module with 3 states as an itemrenderer. The states are called Movies, Songs and TvShows. The base state is empty. The itemRenderer consists of Hbox, Vboxes and labels.
And I have created a List component.
What I want to do is to populate data in my List component and make it visible using my ItemRenderer. Depending on the data that is pulled out from the database I want to show the itemRenderer's correct state. Hence if the record pulled out from the database is a song, I want to display the Song state, if it is a movie, I want to show the Movie state and so on.
So depending on the data that's pulled out, I would like to change the current state of itemrenderer. How would i do that?
Can anybody show me an example how i would make this code?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
重写 CustomItemRenderer 的
set data
方法并根据数据分配适当的状态。override the
set data
method of your CustomItemRenderer and assign the appropriate state based on the data.谢谢,效果很好。
我唯一注意到的是:
应该
感谢
DJ
thanks it worked well.
The Only thing i notice was that:
should be
thanks
DJ
使用上述选项,您需要通过循环数据数组集合并将类型设置为另一个状态名称来调整所有数据。
也许更好的解决方案是循环遍历列表中的所有项目并更改状态;
如果您使用 useVirtualLayout="true" 这将不起作用,它只会影响可见项目。
with the above option you need to adjust all your data by looping trough your data arraycollection and setting the type to another state name.
Perhaps a better solution is looping trough all items of the list and change the state;
This will not work if you use useVirtualLayout="true" it then would only affect the visible items.