访问 itemRenderer 实例 flash builder 4

发布于 2024-09-10 15:56:57 字数 670 浏览 7 评论 0原文

我的设置非常基本。我有一个 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 技术交流群。

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

发布评论

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

评论(1

审判长 2024-09-17 15:56:57

Lists/ItemRenderers 的概念模型是它们是 dataProvider 中项目的表示。记住这一点的原因之一是列表回收它们的 ItemRenderer 以减少内存占用。这意味着您的 dataProvider 中可能有 100 个项目,但其中只有一小部分具有与其关联的 ItemRenderer,其中一些甚至可能在屏幕上不可见,甚至不再有效。有几种方法可以让列表中的 ItemRenderer 反映 List 父级的状态,而无需直接操作渲染器。例如,您可以执行如下操作:

<s:List id="layersList" 
        borderVisible="false" 
        allowMultipleSelection="true" 
        dataProvider="{AssetsCollection}"
        contentBackgroundAlpha="0">
    <s:layout>
        <s:VerticalLayout gap="1" />      
    </s:layout>
    <s:itemRenderer>
        <fx:Component>
            <myrenderers:TestRenderer myState="{outerDocument.someState}"/>
        </fx:Component>
    </s:itemRenderer>
</s: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:

<s:List id="layersList" 
        borderVisible="false" 
        allowMultipleSelection="true" 
        dataProvider="{AssetsCollection}"
        contentBackgroundAlpha="0">
    <s:layout>
        <s:VerticalLayout gap="1" />      
    </s:layout>
    <s:itemRenderer>
        <fx:Component>
            <myrenderers:TestRenderer myState="{outerDocument.someState}"/>
        </fx:Component>
    </s:itemRenderer>
</s:List>

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.

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