将变量绑定到 ItemRender 组件属性
我想将 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 。 你如何做到这一点?
我希望你能理解我的问题。
谢谢!
文森特
I would like to bind a variable from my ActionScript to a property of a component that is in a ItemRender. But I always get this error:
1120: Access of undefined property
currentRoom.
Here is my code
<?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>
I would like to use the object currentRoom in my ItemRenderer component.
How do you do this?
I hope you understand my question.
Thanks!
Vincent
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题在于
定义声明了一个新范围。因此它无法直接访问当前的 mxml 文件范围。
只是用于原型设计以快速草稿的快捷方式。但从范围的角度来看,这与将组件提取到单独的文件中是一样的。所以提取它并停止混淆:)The problem is that
<mx:Component>
definition declares a new scope. So it can't access current mxml file scope directly.<mx:Component>
is just a shortcut for prototyping purposes to have a quick draft. But from the scope point of view it is the same as if you extract your component in a separate file. So extract it and stop be confusing :)一个简短的解决方案是使用 outerDocument ,有关
详细信息,请阅读了解 Flex itemRenderers
希望有帮助
One short solution is using outerDocument as
for details read Understanding Flex itemRenderers
Hopes that helps