Flex 3:使用中继器和中继器向组件发送 XML 信息...遇到一些问题
我尝试导入 XML 文件,并将零碎的内容发送到自定义组件。
我的 XML 文件的结构如下:
<projects>
<project>
<projName>{Insert title of project here}</projName>
<startDate>{Insert date here}</startDate>
<positions>
<daysOffset>{Insert a number here}</daysOffset>
<numDays>{Insert a number here}</daysOffset>
<role>{Insert role here}</role>
<student>{Insert name here}</student>
</positions>
// There can be an unlimited amount of positions listed
</project>
// There can be an unlimited amount of projects listed
我使用以下命令读取 XML 数据:
<mx:XML id="projectsXML" xmlns="" source="xml/projects.xml" format="e4x" />
导入 XML 后,我尝试使用转发器将每个标记内的信息发送到自定义组件。我的代码如下:
<mx:Canvas width="100%" height="95%" x="0" y="80">
<mx:Repeater id="projectRP" dataProvider="{projectsXML}">
<Block:project
oneDay="{usableSize.width/14}"
projectTitle="{projectRP.currentItem.project.projName}"
projectDate="{projectRP.currentItem.project.startDate}"
projectPositions="{projectRP.currentItem.project.positions as Array}"
/>
</mx:Repeater>
</mx:Canvas>
当我保存项目时,我没有收到任何错误或警告。但是,当我尝试输出组件中的值时,projectPositions 部分返回为 Null。
有人有什么想法吗?这两天我一直在试图解决这个问题,但我完全被难住了:(
I trying to import an XML file, and send bits and pieces to a custom component.
My XML file is structured like this:
<projects>
<project>
<projName>{Insert title of project here}</projName>
<startDate>{Insert date here}</startDate>
<positions>
<daysOffset>{Insert a number here}</daysOffset>
<numDays>{Insert a number here}</daysOffset>
<role>{Insert role here}</role>
<student>{Insert name here}</student>
</positions>
// There can be an unlimited amount of positions listed
</project>
// There can be an unlimited amount of projects listed
I read in the XML data by using the following command:
<mx:XML id="projectsXML" xmlns="" source="xml/projects.xml" format="e4x" />
After the XML is imported, I try to use a repeater to send the information within each tag to a custom component. My code is below:
<mx:Canvas width="100%" height="95%" x="0" y="80">
<mx:Repeater id="projectRP" dataProvider="{projectsXML}">
<Block:project
oneDay="{usableSize.width/14}"
projectTitle="{projectRP.currentItem.project.projName}"
projectDate="{projectRP.currentItem.project.startDate}"
projectPositions="{projectRP.currentItem.project.positions as Array}"
/>
</mx:Repeater>
</mx:Canvas>
When I save the project, I do not get any errors or warnings. However, when I attempt to output the values in the component, the projectPositions piece comes back as Null.
Anybody have any ideas? I've been trying to figure this out for the better part of two days, and I'm completely stumped :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将
projectRP.currentItem.project.positions
转换为Array
,但它是XMLList
。因此,在转换后,您将得到null
。You're casting
projectRP.currentItem.project.positions
asArray
but it isXMLList
. So after casting you havenull
.