【问题标题】:Bind variable to ItemRender component property将变量绑定到 ItemRender 组件属性
【发布时间】:2011-05-16 07:28:17
【问题描述】:

我想将我的 ActionScript 中的变量绑定到 ItemRender 中组件的属性。但我总是得到这个错误:

1120: 未定义属性的访问 当前房间。

这是我的代码

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:solutionItems="com.barco.components.ControlRoomConfigurator.solutionItems.*">
    <mx:Script>
        <![CDATA[
            import com.barco.VO.ControlRoomConfigurator.Room;

            [Bindable] private var myArrayCollection:ArrayCollection;
            [Bindable] public var currentRoom:Room;


        ]]>
    </mx:Script>
    <mx:List id="listVideoWalls" 
         borderThickness="0"
         dataProvider="{myArrayCollection}" >
        <mx:itemRenderer>
            <mx:Component>
                <solutionItems:displaySolutionItem solutionId="{data.meetsRequirements.getItemAt(currentRoom.id)}" />
            </mx:Component>
        </mx:itemRenderer>
    </mx:List>
</mx:Canvas>

我想在我的 ItemRenderer 组件中使用对象 currentRoom。 你是怎么做到的?

希望你能理解我的问题。

谢谢!

文森特

【问题讨论】:

    标签: apache-flex actionscript-3 flash-builder itemrenderer


    【解决方案1】:

    问题在于&lt;mx:Component&gt; 定义声明了一个新范围。所以它不能直接访问当前的 mxml 文件范围。 &lt;mx:Component&gt; 只是原型设计的捷径,可以快速草稿。但从范围的角度来看,这与将组件提取到单独的文件中是一样的。所以提取它并停止混淆:)

    【讨论】:

      【解决方案2】:

      一个简短的解决方案是使用 outerDocument 作为

      solutionId="{data.meetsRequirements.getItemAt(outerDocument.currentRoom.id)}"
      

      详情请阅读Understanding Flex itemRenderers

      希望有帮助

      【讨论】:

      • -1。非常糟糕的做法,因为现在您假设 outerDocument 将始终具有该属性。
      • 我写了它的简短解决方案:)
      猜你喜欢
      • 1970-01-01
      • 2021-11-30
      • 2014-01-14
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      • 2014-04-23
      • 2020-08-09
      • 1970-01-01
      相关资源
      最近更新 更多