【问题标题】:Flex TileList with associative array具有关联数组的 Flex TileList
【发布时间】:2010-04-07 22:16:59
【问题描述】:

我有一个要使用 TileList 显示的关联数组。但是,它不明白喂给它的是什么。我得到的只是 TileList 中的 [object]。

[bindable]
public var people as array = new array();

private function loadArray():void{
people = decoded JSON array
showPeople.dataProvider = people;}

<mx:Tilelist id="showPeople" labelField="{data.name}" iconField="{data.imgURL}"/>

我尝试使用 mx:itemRender 但它只会呈现一个且只有一个项目,即人名的字符串或 url 的图像。最终目标是让 TileList 使用数组中的 URL 及其名称作为标签显示一个人的图片。有什么建议吗?

数组看起来像这样 'name' => 人名字符串 'img' => img URL 字符串

【问题讨论】:

  • 你是什么意思 [object] ?你确定它正确解码了 JSON 数组吗?

标签: apache-flex associative-array tilelist


【解决方案1】:

您应该使用自定义项目渲染器,如下所示:

<mx:itemRenderer>
  <mx:Component>
    <mx:HBox>
      <mx:Text width="100" height="100" text="{data.name}"/>
      <mx:Image width="100" height="100" source="{data.imgURL}"/>
    </mx:HBox>
  </mx:Component>
</mx:itemRenderer> 

通过这种方式,您可以根据需要自定义列表项。

【讨论】:

  • 当我说 [Object] 时,我的意思是它在 Tilelist 所在的面板中显示了“[Object]”字样。 Cornel 的回答非常完美。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-15
  • 2011-01-15
相关资源
最近更新 更多