Hi, I am in the process of combing the ESRI Dynamic Map Layers on/off Flex Sample and ESRI Legend Component Flex Sample into one application; however, I am getting a #1034: Type Coercion error when I toggle a layer. When it comes to Flex programming I am a real novice or more of a hack, my background is SQL and VB, so please bear with me. My interpretation of the error is that I am somehow generating a type miss-match between the data structure used for the Layers list and the structure used for the Legend display. I thought both of these structures used an array that was populated by Dynamic Service, myDynamicService, therefore, I am very confused as to what is going on here. I have attached a copy of my source files but here is the code for the Default mxml:<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
xmlns:samples="com.*"
pageTitle="Layers and Legends">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function application1_initializeHandler(event:FlexEvent):void
{
myLegend.layers = [ myDynamicService ];
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout horizontalAlign="center"
paddingBottom="20"
paddingLeft="20"
paddingRight="20"
paddingTop="20"/>
</s:layout>
<mx:HDividedBox width="100%" height="100%">
<esri:Map id="myMap">
<esri:ArcGISDynamicMapServiceLayer id="myDynamicService" name=" "
load="myDynamicService.defaultVisibleLayers()"
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer"/>
</esri:Map>
<mx:VBox width="40%" height="100%">
<mx:Panel width="100%" height="50%" borderVisible="true" borderColor="#030303" title="Layers">
<samples:LayerTOC mapLayer="{myDynamicService}"/>
</mx:Panel>
<mx:Panel width="100%" height="50%" borderVisible="true" borderColor="#030303" title="Legend">
<esri:Legend id="myLegend"
width="100%" height="100%"
map="{myMap}"
respectCurrentMapScale="true"/>
</mx:Panel>
</mx:VBox>
</mx:HDividedBox>
</s:Application>
I hope someone can explain to me what is happening here to generate the Coercion error and hopefully help me resolve it so I can get the Legend to reflect what is displayed on the map. Any help provided will be greatly appreciated, thank you.- Greg