0

SQLite我有一个填充了来自数据库的输入的数组。当我将此数组用作 as:list 的数据提供者时,它将显示我指定的数组中的所有对象。
我想访问数组中的一些对象,并且一直在尝试使用getItemAt(). 目前我可以返回数组中的第一个对象,但是更改索引(getItemAt(1)例如),它什么也不返回。

最终,我的目标是使用在应用程序其他地方输入并插入SQLite数据库的数据填充 FX:Model。然后,该模型充当饼图的数据提供者。我可以将数据库的第一个条目传递给模型/饼图,但不能访问其他条目。

一些相关的代码部分如下。故障排除提示将不胜感激。

[Bindable]
    private var GHGsource:ArrayCollection;

进而:

            GHGsource = new ArrayCollection();
        }
        for each ( var o:Object in event.data )
        {
            GHGsource.addItem(o);
        }
        FullList.dataProvider = GHGsource;
    }
}

模型设置:

<fx:Declarations>
    <fx:Model id="GHG" >
<data>
<row>
<input>Enteric methane</input>
<Value> {GHGsource.getItemAt(0).answer}  </Value>

列表设置:

<s:List id="FullList">
  <s:itemRenderer>
    <fx:Component>
      <s:IconItemRenderer labelFunction="returnQuestion" messageFunction="returnAnswer">
        <fx:Script>
          <![CDATA[                             
            private function returnQuestion(item:Object):String
            {
                return "Question: " + item.question;
            }
            private function returnAnswer(item:Object):String
            {
                var response:String = "";
                if ( !item.answer || item.answer == "" )
                {
                    response = "(no response)";
                } else {
                    response = item.answer;
                }
                return response;
            }
          ]]>
        </fx:Script>
      </s:IconItemRenderer>
    </fx:Component>
  </s:itemRenderer>
</s:List>

此应用程序基于Daniel Koestler 的调查猿应用程序中列出的数据库结构。

也许深入了解 s:List 组件如何访问数组中的对象会有所帮助?

附加细节:

在调试模式下运行,似乎对象没有正确绑定到 arraycollection。警告:无法绑定到类“对象”上的属性“xxx”(类不是 IEventDispatcher)

我试图按照以下链接上的指南进行操作,但没有成功。
链接1 链接 2

4

1 回答 1

0

好的,我知道了。

   GHGsource = new ArrayCollection();
    }
    for each ( var o:Object in event.data )
    {
        GHGsource.addItem(o);
    }
    FullList.dataProvider = GHGsource;
 }
}

变成:

[Bindable]
private var passingArray:Array;

和:

   GHGsource = new ArrayCollection();
   passingArray = new Array();

    }
    for each ( var o:Object in event.data )
    {
        GHGsource.addItem(o);
        passingArray[o] = new ObjectProxy(event.data[o]);
    }
    // not needed as the list is no longer needed - FullList.dataProvider = GHGsource;
}
}

然后这个工作:

<fx:Declarations>
<fx:Model id="GHG" >
<data>
<row>
<input>Enteric methane</input>
<Value> {GHGsource.getItemAt(3).answer}  </Value>
于 2012-10-04T14:35:19.167 回答