I haven't done this, but I do save visible layers when user close the appliaction and load them when the user opens it again. The code I use for saving och loading visible layers might help you.Saving visible layers to SharedObjects:settingsSO = SharedObject.getLocal("HlsbgSettings");
var map:Map = ViewerContainer.getInstance().mapManager.map
acVisLayers = new ArrayCollection();
MapUtil.forEachMapLayer(map, function(layer:Layer):void {
var layVisAc:ArrayCollection;
if (layer is ArcGISDynamicMapServiceLayer) {
layVisAc = ArcGISDynamicMapServiceLayer(layer).visibleLayers;
} else if (layer is ArcIMSMapServiceLayer) {
layVisAc = ArcIMSMapServiceLayer(layer).visibleLayers;
} else if (layer is ArcGISTiledMapServiceLayer) {
layVisAc = ArcGISTiledMapServiceLayer(layer).visibleLayers;
}
var lvisObj:Object = {
name: layer.name,
visible: layer.visible,
visarray: layVisAc
}
acVisLayers.addItem(lvisObj);
});
settingsSO.data[VISLAYERS] = acVisLayers;
settingsSO.flush();
visible layers from SharedObjects:settingsSO = SharedObject.getLocal("HlsbgSettings");
if (settingsSO.size > 0) {
var acVisLayers:ArrayCollection = settingsSO.data.vislayers as ArrayCollection;
if (acVisLayers.length > 0){
MapUtil.forEachMapLayer(map, function(layer:Layer):void {
var cLayId:int = 0;
for(var i:Number=0; i < acVisLayers.length -1;i++)
{
if(acVisLayers.name == layer.name)
{
cLayId = i;
break;
}
}
if (layer is ArcGISDynamicMapServiceLayer) {
layer.visible = acVisLayers[cLayId].visible;
ArcGISDynamicMapServiceLayer(layer).visibleLayers = acVisLayers[cLayId].visarray;
} else if (layer is ArcIMSMapServiceLayer) {
layer.visible = acVisLayers[cLayId].visible;
ArcIMSMapServiceLayer(layer).visibleLayers = acVisLayers[cLayId].visarray;
} else if (layer is ArcGISTiledMapServiceLayer) {
layer.visible = acVisLayers[cLayId].visible;
}
});
}
}
}
(The code is actually from something Robert Scheitlin wrote for SFV 1.3 that I've modified just a little bit to work in my SFV 2.1)