0
votes

i'm using flash builder 4..i want to ask something..how to binding data to custom list component in flex??...

i already try binding data from webservice to standard datagrid component in flex, and it's work perfectly...this is my code for binding to datagrid..

<mx:DataGrid includeIn="LobbyPage" x="30" y="319" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{TakeUserResult4.lastResult}">
    <mx:columns>
        <mx:DataGridColumn headerText="Username" dataField="Username"/>
        <mx:DataGridColumn headerText="Password" dataField="Password"/>
    </mx:columns>
</mx:DataGrid>

now i'm stuck with this..i have custom list like i wrote below..

<s:List skinClass="components.DataList4" x="18" y="611" id="listPlayer">

<s:ArrayCollection>

  <fx:Object image1="@Embed('/assets/images/test aj/basil.png')" text1="FLAVOR"   
        text2="Description of the flavor goes here"/>

  <fx:Object image1="@Embed('/assets/images/test aj/basil.png')" text1="FLAVOR" 
        text2="Description of the flavor goes here"/>

  <fx:Object image1="@Embed('/assets/images/test aj/basil.png')" text1="FLAVOR" 
        text2="Description of the flavor goes here"/>

</s:ArrayCollection>

</s:List>

now..how to bind data to "image1","text1","text2" from webservice?? anyone who want to share an experience to this stuff and give me example?thanks in advance.. by the way..sorry for my bad english :)

1
well..i'm already put my code for datagrid..thanks for your advice constantiner - Selalu_Ingin_Belajar

1 Answers

2
votes

Give your list a dataProvider (wrap your array collection in the data provider tag) then specify an itemRenderer so the list knows how to render the data.

<s:List id="listPlayer" width="200" height="500">
                        <s:dataProvider>
                            <s:ArrayCollection>
                                <fx:Object image1="@Embed('/assets/images/test aj/basil.png')" text1="FLAVOR"   
                                           text2="Description of the flavor goes here"/>

                                <fx:Object image1="@Embed('/assets/images/test aj/basil.png')" text1="FLAVOR" 
                                           text2="Description of the flavor goes here"/>

                                <fx:Object image1="@Embed('/assets/images/test aj/basil.png')" text1="FLAVOR" 
                                           text2="Description of the flavor goes here"/>
                            </s:ArrayCollection>
                        </s:dataProvider>
                        <s:itemRenderer>
                            <fx:Component>
                                <s:ItemRenderer>
                                    <s:HGroup>
                                        <s:Image source="{data.image1}" />
                                        <s:Label text="{data.text1}" fontWeight="bold"/>
                                        <s:Label text="{data.text2}" />
                                    </s:HGroup>
                                </s:ItemRenderer>
                            </fx:Component>
                        </s:itemRenderer>
                    </s:List>