image - Flex列表控件itemrenderer问题

标签 image flex4 itemrenderer

我正在制作一个小型照片库。我创建一个 xml 文件并尝试使用 itemrenderer 将其链接到我的 List 控件。但是,当我尝试保存文件时,出现访问未定义的属性“数据”错误。我认为我们应该使用“数据”来引用数据对象的当前行。这是我的代码...非常感谢!

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
 <fx:Declarations>
  <fx:Model id="pictureXML" source="data/pictures.xml"/>
  <s:ArrayList id="pictureArray" source="{pictureXML.picture}"/>
 </fx:Declarations>



 <s:List id="pictureGrid" dataProvider="{pictureArray}" 
   horizontalCenter="0" top="20">
  <s:itemRenderer>
   <fx:Component>
    <s:HGroup>
     <mx:Image source="images/big/{data.source}" /> // where the error happen
     <s:Label text="{data.caption}"/> // where the error happen
    </s:HGroup>   

   </fx:Component>
  </s:itemRenderer>
 </s:List>


</s:Application>

我的xml

<?xml version="1.0"?>
<album>
   <picture>
   <source>city1.jpg </source>
   <caption>City View 1</caption>
   </picture>
    <picture>
   <source>city2.jpg </source>
   <caption>City View 2</caption>
   </picture>
     <picture>
   <source>city3.jpg </source>
   <caption>City View 3</caption>
   </picture>
    <picture>
   <source>city4.jpg </source>
   <caption>City View 4</caption>
   </picture>
    <picture>
   <source>city5.jpg </source>
   <caption>City View 5</caption>
   </picture>
    <picture>
   <source>city6.jpg </source>
   <caption>City View 6</caption>
   </picture>
    <picture>
   <source>city7.jpg </source>
   <caption>City View 7</caption>
   </picture>
    <picture>
   <source>city8.jpg </source>
   <caption>City View 8</caption>
   </picture>
    <picture>
   <source>city9.jpg </source>
   <caption>City View 9</caption>
   </picture>
    <picture>
   <source>city10.jpg </source>
   <caption>City View 10</caption>
   </picture>
</album>

感谢任何帮助!

最佳答案

<s:List id="pictureGrid" dataProvider="{pictureArray}" 
   horizontalCenter="0" top="20">
  <s:itemRenderer>
   <fx:Component>
      <s:ItemRenderer>
    <s:HGroup>
     <mx:Image source="images/big/{data.source}" /> // where the error happen
     <s:Label text="{data.caption}"/> // where the error happen
    </s:HGroup>   
    </s:ItemRenderer>
   </fx:Component>
  </s:itemRenderer>
 </s:List>

试试这个!会起作用的

关于image - Flex列表控件itemrenderer问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2796191/

相关文章:

apache-flex - 弹性 : Caching images in list item renderer?

C# Image.Save AccessViolationException

tomcat - 显示融合图表和小部件

flex4 - 从窗口 + AIR 应用程序中删除底部栏

flash - addChild() - DisplayObject 不会立即可见

apache-flex - 强制所有项目渲染器提交commitProperties?

apache-flex - 如何防止 itemRenderer 中的容器超出列表容器的宽度?

image - python : Concatenate 2 irregular sized images by automatically detecting the sizes

javascript - 快速连续隐藏和显示图像时的视觉延迟

jquery - 使对象在 div 换行的约束范围内移动?