Solved! Go to Solution.
<s:Group id="contentGroup" width="30" height="30"/>
legendDataGroup.itemRenderer = new ClassFactory(LegendGroupItemRenderer);
legendDataGroup.itemRenderer = new ClassFactory(MyLegendGroupItemRenderer);
<?xml version="1.0" encoding="utf-8"?>
<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"
name="LegendGroupItemRenderer"
width="230" height="35"
autoDrawBackground="false"
focusEnabled="false"
mouseChildren="false">
<fx:Script>
<![CDATA[
import com.esri.ags.symbols.CompositeSymbol;
import com.esri.ags.symbols.Symbol;
import flashx.textLayout.formats.TextAlign;
import mx.core.IVisualElement;
override public function set data(value:Object):void
{
super.data = value;
//First remove everything from the contentGroup
contentGroup.removeAllElements();
// set style on the label
templateLabel.setStyle("textAlign", TextAlign.CENTER);
templateLabel.text = value.label;
if (value.symbol)
{
if (!(value.symbol is CompositeSymbol)) // do not show legend for composite symbols
{
contentGroup.addElement(IVisualElement(Symbol(value.symbol).createSwatch(contentGroup.width, contentGroup.height)));
}
}
}
]]>
</fx:Script>
<s:HGroup paddingLeft="10" verticalAlign="middle">
<s:Group id="contentGroup"
width="myWidth" height="myHeight"/>
<s:Label id="templateLabel"/>
</s:HGroup>
</s:ItemRenderer>
<esri:Legend id="myLegend" map="{myMap}" layers="{[salesLayer]}" skinClass="MyLegendSkin">