Ian, I didn't extensively test this but seems to do what you are asking for.Just replace your layerLegendData.mxml with this code:<?xml version="1.0" encoding="utf-8"?>
<mx:VBox
xmlns:mx ="http://www.adobe.com/2006/mxml"
xmlns:widgets ="com.esri.solutions.flexviewer.widgets.*"
width ="95%"
minHeight ="22"
backgroundAlpha ="1"
paddingLeft ="9"
paddingRight ="3"
backgroundColor ="#FFFFFF"
includeInLayout="{isVisible}">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var layerName:String;
private var _infoData:Object;
private var ldata:Object;
[Bindable]
private var isVisible:Boolean = false;
[Bindable]
private var isNotSingle:Boolean = true;
[Bindable]
private var isSingle:Boolean = false;
public function get infoData():Object
{
return _infoData;
}
public function set infoData(value:Object):void
{
_infoData = value;
ldata = infoData.ldata;
layerName = infoData.title;
isVisible = infoData.isvis;
if(ldata.length == 1){
isNotSingle = false;
isSingle = true;
var infDataS:Object =
{
icon: ldata[0]["url"],
title: layerName
};
sLegendData.infoData = infDataS;
}else{
isNotSingle = true;
isSingle = false;
var recAC:ArrayCollection = new ArrayCollection();
for (var i:Number = 0; i < ldata.length; i++){
var infData:Object =
{
icon: ldata["url"],
title: ldata["label"]
};
recAC.addItem(infData);
}
legendRepeater.dataProvider = recAC;
}
}
]]>
</mx:Script>
<widgets:LegendData id="sLegendData" includeInLayout="{isSingle}" visible="{isSingle}"/>
<mx:Label text="{layerName}" fontWeight="bold" width="100%" includeInLayout="{isNotSingle}" visible="{isNotSingle}"/>
<mx:Repeater id="legendRepeater" includeInLayout="{isNotSingle}" visible="{isNotSingle}">
<widgets:LegendData infoData="{legendRepeater.currentItem}"/>
</mx:Repeater>
</mx:VBox>
After paying around with this I like it, well something else to do to my website when I get back to work.