Flex 3:使用中继器和中继器向组件发送 XML 信息...遇到一些问题

发布于 2024-11-04 01:16:29 字数 1529 浏览 1 评论 0原文

我尝试导入 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 技术交流群。

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

发布评论

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

评论(1

牛↙奶布丁 2024-11-11 01:16:29

您将 projectRP.currentItem.project.positions 转换为 Array,但它是 XMLList。因此,在转换后,您将得到 null

You're casting projectRP.currentItem.project.positions as Array but it is XMLList. So after casting you have null.

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