访问 itemRenderer 实例 flash builder 4
我的设置非常基本。我有一个 s:List ,其中包含自定义 itemRenderer 和数据提供程序。我想做的是访问项目渲染器生成的实例,但我不知道如何访问。
这是列表的代码:
<s:List id="layersList"
borderVisible="false"
allowMultipleSelection="true"
contentBackgroundAlpha="0"
itemRenderer="renderers.LayerRenderer"
dataProvider="{AssetsCollection}">
<s:layout>
<s:VerticalLayout gap="1" />
</s:layout>
<s:list>
我想要访问生成的渲染器,例如:
layersList.renderers[selectedIndex]或layersList.selectedItems[0].renderer
。为了访问它的一些内部对象。就像在事件中一样,我想监听从列表的父级渲染器实例中分派的事件。
有人可以帮忙吗?
My setup is pretty basic. I have an s:List with a custom itemRenderer and a dataprovider. What I would like to do is access the generated instances of the item renderer but I have no idea how.
Here is the code for the list:
<s:List id="layersList"
borderVisible="false"
allowMultipleSelection="true"
contentBackgroundAlpha="0"
itemRenderer="renderers.LayerRenderer"
dataProvider="{AssetsCollection}">
<s:layout>
<s:VerticalLayout gap="1" />
</s:layout>
<s:list>
What I would like is to access the generated renderers like:
layersList.renderers[selectedIndex] or layersList.selectedItems[0].renderer
. In order to access some of its internal objects. Like in the event I would want to listen events dispatched in the renderer instance from the List's parent.
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Lists/ItemRenderers 的概念模型是它们是 dataProvider 中项目的表示。记住这一点的原因之一是列表回收它们的 ItemRenderer 以减少内存占用。这意味着您的 dataProvider 中可能有 100 个项目,但其中只有一小部分具有与其关联的 ItemRenderer,其中一些甚至可能在屏幕上不可见,甚至不再有效。有几种方法可以让列表中的 ItemRenderer 反映 List 父级的状态,而无需直接操作渲染器。例如,您可以执行如下操作:
其中 TestRenderer 有一个名为 myState 的可绑定公共属性。 List 的父级有一个名为“someState”的可绑定属性。然后在渲染器中,您可以根据 myState 的值设置一些条件逻辑。希望有帮助。
the conceptual model of Lists/ItemRenderers is that they are a representation of the items in the dataProvider. One reason for keeping this in mind is that Lists recycle their ItemRenderers in order to reduce memory footprint. This means you may have 100 items in your dataProvider, but only a small subset of those will have ItemRenderers associated with them, and some of those may not even be visible on screen or even valid any longer. There are a few ways you could approach having your ItemRenderers in your List reflect the state of the List's parent without having to directly manipulate the renderers. For instance, you could do something like this:
Where TestRenderer has a bindable public property called myState. And the List's parent has a bindable property called "someState". Then inside your renderer you can set some conditional logic based on the value of myState. Hope that helps.