Use XML child node as label in Spark list itemRenderer
In ActionScript, I whittle down my XML to a series of nodes, all formed like this:
<option letter="A">
<letter>A</letter>
<response>Thank you</response>
<posFeed>Excellent</posFeed>
<negFeed>Terrible</negFeed>
<score>-1</score>
开发者_如何学C <elimOptions>B</elimOptions>
</option>
When I set this series as the dataProvider for my Spark list that uses a custom item renderer with a Spark label, I set the label.text={data}, which displays each full set of nodes as a list item.
If I don't want to whittle the XML down to just the nodes beforehand (I'd like the full set intact for other functions I have to perform), how can I set just the response node to be the data to use for the label in the itemRenderer? I tried setting the label text={data.response}, but that doesn't work (a full set of nodes still appears as each list item.
Like this:
<fx:Declarations>
<fx:XML id="data">
<options>
<option letter="A">
<letter>A</letter>
<response>Thank you</response>
<posFeed>Excellent</posFeed>
<negFeed>Terrible</negFeed>
<score>-1</score>
<elimOptions>B</elimOptions>
</option>
<option letter="B">
<letter>B</letter>
<response>Thank you B</response>
<posFeed>Excellent B</posFeed>
<negFeed>Terrible B</negFeed>
<score>-1</score>
<elimOptions>B</elimOptions>
</option>
</options>
</fx:XML>
</fx:Declarations>
<s:List labelField="response">
<s:dataProvider>
<s:XMLListCollection source="{data.option}" />
</s:dataProvider>
</s:List>
I should add that when I did this, I didn't have any trouble using a custom item renderer:
<s:List itemRenderer="DataItemRenderer">
<s:dataProvider>
<s:XMLListCollection source="{data.option}" />
</s:dataProvider>
</s:List>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true">
<s:Label text="{data.response}"/>
</s:ItemRenderer>
精彩评论