2011-07-27 22 views
0

我有一个Arraycollection,其中包含其他数组。 我想与要显示的项目里面的数据呈现,但不能管理要做到这一点 这里是示例代码来说明我的问题如何在ITEMRENDER组中显示ArrayCollection | ACTIONSCRIPT

<s:DataGroup dataProvider="{news}" 
       itemRenderer="components.displaynews"> 

,这是该项目呈现

<s:Label text="{data.??/}"/> 

现在我不明白是什么后数据?在数组集合中,数据如下所示:myArrayCollection - > [0] - >名字

所以当im绑定数据到物品渲染时,我该如何表示[x]以获得我想要的特定名称?这obviusly不会工作

<s:Label text="{data.[0].name/}"/> 

还有一件事是什么,是与简单的项目清单\组,以显示数据渲染(图片和文字)

感谢您的帮助提前 10倍的最轻的方式!

  private function convertFBEventData2TreeData(eventData:Object):Object 
     { 
      var children:ArrayCollection = new ArrayCollection(); 
      var numAttrs:Number = 0; 
      for (var attrName:String in eventData) 
      { 
       var val:Object = eventData[attrName]; 
       if (val != null) 
        children.addItem({label:attrName, children:convertFBEventData2TreeData(val)}); 
       numAttrs++; 
      } 
      if (numAttrs == 0 && eventData != null) 
      { 
       children.addItem({label:eventData}); 
      } 
      return children; 
     } 

这是我的数据

eventData [] (@cb73bc9) 
[0] Object (@a3f9461) 
    actions [] (@cb736f1) 
    application null  
    created_time "2011-07-29T11:46:31+0000" 
    from Object (@a49c179) 
    id "100002237793631_139378476146745" 
    message "2 And a half days on a 546 mile load just to find out they wont except the load,when we should b doin 1000 miles a day,somebody needs to get their shit together" 
    type "status"  
    updated_time "2011-07-29T11:46:31+0000" 
[1] Object (@ca53239) 
[2] Object (@d023a49) 
[3] Object (@d029059) 
[4] Object (@cb796e9) 
[5] Object (@d023ce9) 
[6] Object (@cb79809) 
[7] Object (@a49c6e9) 
[8] Object (@d0238c9) 
[9] Object (@d029a19) 
[10] Object (@ca53509) 
[11] Object (@d0261a9) 
[12] Object (@a5b5a91) 
[13] Object (@cb79a61) 
[14] Object (@d025761) 
[15] Object (@d023b09) 
[16] Object (@a49c521) 
[17] Object (@d0258e1) 
[18] Object (@d0232b1) 
[19] Object (@cb80c11) 
[20] Object (@cb3e4c1) 
[21] Object (@a5b25f9) 
[22] Object (@d074491) 
[23] Object (@d02f9e9) 
[24] Object (@d024b81) 
length 25 [0x19] 

有与项目渲染来显示它的方式?我不能设法做

,我把它转换上面的代码的ArrayCollection,然后将数据是这样的:

resultsData mx.collections.ArrayCollection (@918cec1) 
[inherited] 
[0] Object (@d023779) 
[1] Object (@d024f29) 
    children mx.collections.ArrayCollection (@ca1bac1) 
     [inherited] 
     [0] Object (@d0247a9) 
      children mx.collections.ArrayCollection (@ca1bb01) 
      label "updated_time" 
     [1] Object (@d0254f1) 
      children mx.collections.ArrayCollection (@ca1bb41) 
      label "id"  
     [2] Object (@d026d31) 
      children mx.collections.ArrayCollection (@ca1bc01) 
      label "from" 
     [3] Object (@d029461) 
      children mx.collections.ArrayCollection (@ca1bcc1) 
      label "link" 
     [4] Object (@d029b81) 
      children mx.collections.ArrayCollection (@ca1bd01) 
      label "type" 
     [5] Object (@d029b39) 
     [6] Object (@d02d491) 
     [7] Object (@d076671) 
     [8] Object (@d06f941) 
     [9] Object (@cb3e629) 
     [10] Object (@d0235e1) 
     [11] Object (@d0239b9) 
     [12] Object (@d024ef9) 
     source [] (@d07e0d9) 
    label "1" 
[2] Object (@d023269) 
[3] Object (@d02f941) 
[4] Object (@d02d6d1) 
[5] Object (@d023479) 
[6] Object (@d076491) 
[7] Object (@cb3ea19) 
[8] Object (@cf9b4a9) 
[9] Object (@cf992f9) 
[10] Object (@cfac689) 
[11] Object (@cfa9d19) 
[12] Object (@d0797d9) 
[13] Object (@d02b2b1) 
[14] Object (@d02ffb9) 
[15] Object (@d025ca1) 
[16] Object (@cfa2629) 
[17] Object (@cfac2c9) 
[18] Object (@cfb8c71) 
[19] Object (@cfc4bb1) 
[20] Object (@cfb8a91) 
[21] Object (@cf99bb1) 
[22] Object (@d0ad569) 
[23] Object (@c9681f1) 
[24] Object (@d0a7959) 
source [] (@ca7c061) 

和我的方式也不能相信,使其显示在项目呈现!

项目渲染代码是相当简单

<label text={data.??"> 

我不知道该怎么添加数据后,我尝试了很多东西,但没有工作\:

+0

发表您的数据样本,并发布您当前的渲染器“displaynews”不要害羞与您的代码,我们不会笑 –

+0

即时通讯添加它在我的问题和我的代码是有点低劣\: – gongo12

+0

好吧刚刚计算出点东西!当即时通讯写入我的应用程序<标签文本= {新闻[0] .type}它的作品。但即时通讯在我的应用程序DATAPROVIDER = {news}中提供错误是类型错误:错误#1034:类型强制失败:无法转换[] @ c80cb79到mx.collections.IList。 – gongo12

回答

0

该项目渲染已经是一个叫做set data功能在幕后自动调用(在父类中)。所以数据,不是一个数组......它是你的ROW。所以你只需要简单地做{data.name},假设一个对象在属性“name”的数组集合中。

如果你的数组集合是简单的字符串...那么你只需使用{data}。如果你有一个包含图像位置和名称的对象,那么只需按照你命名的方式绑定到这些属性即可。

希望这会有所帮助!

+0

10x为您的答案,但我仍然无法设法做到这一点。当我有一个包含其他对象的arraycollection时,我该怎么办?它包含其他对象吗?例如myarray - >男性 - > over30 - >名字 - >大卫/我如何显示“大卫”与物品渲染? 10x – gongo12

+0

你能展示一些代码吗?我很困惑你的数组/对象结构。 –

+0

ofcourse。我正在做的是从FACEBOOK中精确地接收“新闻源”,即时将对象转换为数组。将该代码添加到我的问题中。将im从facebook转换为arraycollection后,我想“打印”它,但我需要完全控制什么即时打印。在“状态”的情况下做到这一点,在其他情况下做到这一点。但我甚至不能设法使用项目渲染“打印”对象。 10倍很多你的帮助! – gongo12

相关问题