Reputation: 2801
Im making an application for a person search. I get the results in the form of a string (each line representing one person). I want to display these lines of text in a List, how do I do this?
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="PersonSearchResults">
<fx:Script>
<![CDATA[
import model.PersonSummary;
import mx.collections.ArrayCollection;
public var listOfPeople:Array;
public function populate():void{
trace("Populating");
listOfPeople = String(data).split("\n");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:List id="results">
<s:ArrayList source="{listOfPeople}"/>
</s:List>
The problem I am having is that the listOfPeople array populates AFTER the list has displayed on screen... how do I resolve this?
Thanks phil
Upvotes: 1
Views: 848
Reputation: 8875
You can't do bindings with an Array. Use ArrayCollection instead.
[Bindable]
public var listOfPeople:ArrayCollection;
public function populate():void{
listOfPeople = new ArrayCollection(String(data).split("\n"));
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:List id="results" dataProvider="{listOfPeople}" />
Upvotes: 3