I have an array populated with input from an SQLite
database. When I use this array as the dataprovider for a s:list then it will display all the objects in the array that I specify.
I would like to access some of the objects in the array, and have been trying to use getItemAt()
. At the moment I can return the first object in the array, but changing the index (to getItemAt(1)
for example), it returns nothing.
Ultimately I am aiming to populate an FX:Model with data entered elsewhere in the application and inserted into the SQLite
database. The model then acts as the dataprovider for a pie chart. I can pass the first entry of the database on to the model/pie chart, but can't access others.
Some relevant sections of code are as follows. Trouble shooting tips would be appreciated.
[Bindable]
private var GHGsource:ArrayCollection;
And then:
GHGsource = new ArrayCollection();
}
for each ( var o:Object in event.data )
{
GHGsource.addItem(o);
}
FullList.dataProvider = GHGsource;
}
}
Model setup:
<fx:Declarations>
<fx:Model id="GHG" >
<data>
<row>
<input>Enteric methane</input>
<Value> {GHGsource.getItemAt(0).answer} </Value>
List setup:
<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>
This application is based on the database structures set out in Daniel Koestler's survey ape application.
Perhaps an insight into how the s:List component accesses objects in an array will help here?
Additional detail:
Running in debug mode it seems as though that the objects are not binding correctly to the arraycollection. warning: unable to bind to property 'xxx' on class 'Object' (class is not an IEventDispatcher)
I have tried to follow guides on the following links, but have not been sucessfull.
link1
link2