1118: Implicit coercion of a value with static type mx.collections:IList to a possibly unrelated type mx.collections:ArrayCollection.
public function showLayer(layerInfo:LayerInfo):void { var visibleLayers:ArrayCollection; if (layer is ArcGISDynamicMapServiceLayer) { visibleLayers = ArcGISDynamicMapServiceLayer(layer).visibleLayers; visibleLayers.addItem(layerInfo.layerId); // add id }
Solved! Go to Solution.
ArcGISDynamicMapServiceLayer(layer).visibleLayers;
private function buildVisibleLayers(value:Array):ArrayCollection { var ac:ArrayCollection = new ArrayCollection(); var li:LayerInfo for each( li in value){ if(li.defaultVisibility) ac.addItem(li.layerId); } return ac; }
if(!ArcGISDynamicMapServiceLayer(layer).visibleLayers){ visibleLayers = buildVisibleLayers(ArcGISDynamicMapServiceLayer(layer).layerInfos); }else{ visibleLayers = ArcGISDynamicMapServiceLayer(layer).visibleLayers as ArrayCollection; }
ArcGISDynamicMapServiceLayer(layer).visibleLayers;
private function buildVisibleLayers(value:Array):ArrayCollection { var ac:ArrayCollection = new ArrayCollection(); var li:LayerInfo for each( li in value){ if(li.defaultVisibility) ac.addItem(li.layerId); } return ac; }
if(!ArcGISDynamicMapServiceLayer(layer).visibleLayers){ visibleLayers = buildVisibleLayers(ArcGISDynamicMapServiceLayer(layer).layerInfos); }else{ visibleLayers = ArcGISDynamicMapServiceLayer(layer).visibleLayers as ArrayCollection; }