1

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

1 Answer 1

3

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}" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.