<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" 
 xmlns:esri="http://www.esri.com/2008/ags"
 >
 <mx:Script>
  <![CDATA[
   import mx.events.ItemClickEvent;
   import mx.collections.ArrayCollection;
   import mx.controls.RadioButton;
   
   private function loadLayerName():void
   {
    layerPanel.removeAllChildren();
    
    //loop through each layer and add as a radiobutton
    for(var i:uint = 0; i < (dynamicLayer.layerInfos.length); i++) 
    {
     var radioBtn:RadioButton = new RadioButton;
     radioBtn.groupName = "radioBtnGroup";
     radioBtn.value = i;
     radioBtn.label = dynamicLayer.layerInfos.name;
     layerPanel.addChild(radioBtn);
    }
    
    //set the visible layer the first radio button
    radioBtnGroup.selectedValue = 0;
    dynamicLayer.visibleLayers = new ArrayCollection([0]);
   }
   
   private function radioClickHandler(event:ItemClickEvent):void
   {
    // update the visible layers to only show the layer selected
    dynamicLayer.visibleLayers = new ArrayCollection([event.index]);
   }
  ]]>
 </mx:Script>
 
 
 <esri:Map id="myMap">
  <esri:extent>
            <esri:Extent xmin="-126" ymin="27" xmax="-72" ymax="50">
                <esri:SpatialReference wkid="4326"/>
            </esri:Extent>
        </esri:extent>
        <esri:ArcGISDynamicMapServiceLayer id="dynamicLayer"
   load="loadLayerName()"
   url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/{myURL.selectedItem}/MapServer" />
    </esri:Map>
 
 <mx:ComboBox id="myURL" selectedIndex="0" horizontalCenter="0">
        <mx:Array>
            <mx:String>Specialty/ESRI_StateCityHighway_USA</mx:String>
            <mx:String>Specialty/ESRI_StatesCitiesRivers_USA</mx:String>
            <mx:String>Demographics/ESRI_Census_USA</mx:String>
        </mx:Array>
    </mx:ComboBox>
    
 <mx:Panel id="layerPanel" width="300" height="250" x="20" y="250" paddingLeft="20">
  <mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)"/>
 </mx:Panel>
 
</mx:Application>
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		Hi, Try this one out. It will add all layers automatically and make the first layer visible.<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:esri="http://www.esri.com/2008/ags" > <mx:Script> <![CDATA[ import mx.events.ItemClickEvent; import mx.collections.ArrayCollection; import mx.controls.RadioButton; private function loadLayerName():void { layerPanel.removeAllChildren(); //loop through each layer and add as a radiobutton for(var i:uint = 0; i < (dynamicLayer.layerInfos.length); i++) { var radioBtn:RadioButton = new RadioButton; radioBtn.groupName = "radioBtnGroup"; radioBtn.value = i; radioBtn.label = dynamicLayer.layerInfos.name; layerPanel.addChild(radioBtn); } //set the visible layer the first radio button radioBtnGroup.selectedValue = 0; dynamicLayer.visibleLayers = new ArrayCollection([0]); } private function radioClickHandler(event:ItemClickEvent):void { // update the visible layers to only show the layer selected dynamicLayer.visibleLayers = new ArrayCollection([event.index]); } ]]> </mx:Script> <esri:Map id="myMap"> <esri:extent> <esri:Extent xmin="-126" ymin="27" xmax="-72" ymax="50"> <esri:SpatialReference wkid="4326"/> </esri:Extent> </esri:extent> <esri:ArcGISDynamicMapServiceLayer id="dynamicLayer" load="loadLayerName()" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/{myURL.selectedItem}/MapServer" /> </esri:Map> <mx:ComboBox id="myURL" selectedIndex="0" horizontalCenter="0"> <mx:Array> <mx:String>Specialty/ESRI_StateCityHighway_USA</mx:String> <mx:String>Specialty/ESRI_StatesCitiesRivers_USA</mx:String> <mx:String>Demographics/ESRI_Census_USA</mx:String> </mx:Array> </mx:ComboBox> <mx:Panel id="layerPanel" width="300" height="250" x="20" y="250" paddingLeft="20"> <mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)"/> </mx:Panel> </mx:Application>
