The following example shows how you can create a multi-column custom item renderer for a Flex Gumbo FxList control by setting the itemRenderer property.
Full code after the jump.
To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see “Using the beta Gumbo SDK in Flex Builder 3″.
<?xml version="1.0"?>
<!-- -->
<FxApplication name="FxList_itemRenderer_test"
xmlns="http://ns.adobe.com/mxml/2009"
backgroundColor="white">
<layout>
<BasicLayout />
</layout>
<Script>
<![CDATA[
private function comboBox_labelFunc(item:Object):String {
return item.name + "\t" + currFormatter.format(item.price);
}
]]>
</Script>
<Declarations>
<CurrencyFormatter id="currFormatter" precision="2" />
</Declarations>
<FxList id="comboBox"
labelFunction="comboBox_labelFunc"
itemRenderer="TabItemRenderer"
horizontalCenter="0"
verticalCenter="0"
width="200">
<dataProvider>
<ArrayCollection>
<Object name="The" price="0.23" />
<Object name="quick" price="1.03" />
<Object name="brown" price="0.98" />
<Object name="fox" price="1.19" />
<Object name="jumps" price="0.28" />
<Object name="over" price="0.42" />
<Object name="the" price="0.09" />
<Object name="lazy" price="0.81" />
<Object name="dog" price="0.72" />
</ArrayCollection>
</dataProvider>
</FxList>
</FxApplication>
The custom item renderer, TabItemRenderer, is as follows:
<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<ItemRenderer name="TabItemRenderer"
xmlns="http://ns.adobe.com/mxml/2009"
focusEnabled="false">
<states>
<State name="normal"/>
<State name="hovered"/>
<State name="selected"/>
</states>
<Rect left="0" right="0" top="0" bottom="0">
<fill>
<SolidColor color="{contentBackgroundColor}" />
</fill>
<fill.hovered>
<SolidColor color="{rollOverColor}" />
</fill.hovered>
<fill.selected>
<SolidColor color="{selectionColor}" />
</fill.selected>
</Rect>
<TextGraphic id="labelElement"
tabStops="E192"
verticalCenter="0"
left="3"
right="3"
top="6"
bottom="4"/>
</ItemRenderer>
This entry is based on a beta version of the Flex Gumbo SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex Gumbo SDK.
