2011-07-27 32 views
0

我使用Flash Builder中4..i要something..how問到柔性數據綁定到自定義列表組件?? ...數據綁定到自定義的Flex組件

我已經嘗試結合從Web服務到柔性標準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> 

現在我只能堅持this..i具有自定義列表像我寫的以下..

<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> 

現在..如何將數據綁定到webservice的「image1」,「text1」,「text2」? 誰想要分享這個東西的經驗,並給我例子?在此先感謝.. 的方式..我的英語不好:) :)

+0

嗯..我已經把我的代碼爲datagrid ..感謝您的建議constantiner –

回答

2

給你的清單一個dataProvider(包裝你的數組集合數據提供者標籤),然後指定一個itemRenderer,以便列表知道如何呈現數據。

<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>