private function mapClickHandler(event:MapMouseEvent):void{
    clickGraphicsLayer.clear();
                                Alert.show("mouseClicked");
    
    var identifyParams:IdentifyParameters = new IdentifyParameters();
     identifyParams.returnGeometry = true;
     identifyParams.tolerance = 5;
     identifyParams.width = map.width;
     identifyParams.height = map.height;
     identifyParams.geometry = event.mapPoint;
     identifyParams.mapExtent = map.extent;
     identifyParams.spatialReference = map.spatialReference;
    
    var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym);
    clickGraphicsLayer.add(clickGraphic);
    identifyTask.addEventListener(IdentifyEvent.EXECUTE_COMPLETE, myResultFunction);
    identifyTask.execute(identifyParams);
    
    
        //why does this entire function repeat itself based on the number of times the map has been clicked??????????????????????????
        function myResultFunction(event:IdentifyEvent):void
        {
         Alert.show("test1");
         
         var results:Array = event.identifyResults;
         
         if (results && results.length > 0)
         {
          Alert.show("test2");
          
          var result:IdentifyResult = results[0];
          var resultGraphic:Graphic = result.feature;
          var resultObj:Object = results[0].feature.attributes;
          // Alert.show(resultGraphic.attributes.toString());
          
          switch (resultGraphic.geometry.type){
           case Geometry.MAPPOINT:
           {
            Alert.show("test3");
            
            resultGraphic.symbol = selectSymbol;
            clickGraphicsLayer.add(resultGraphic);
            break;
           }
           case Geometry.POLYLINE:
           {
            //resultGraphic.symbol = slsIdentify;
            break;
           }
           case Geometry.POLYGON:
           {
            //resultGraphic.symbol = sfsIdentify;
            break;
           }
          }
          
          Alert.show("test4");
          
          lastIdentifyResultGraphic = resultGraphic;
          
          //switch to the proper table..
          var layerId:Number = result.layerId;
          var vbox:VBox = VBox(tn.getChildByName(myDynamicService.layerInfos[layerId].name+"_tab"));
          
          tn.selectedChild = vbox;
                   
          //switch to proper row in table..
          var datagrid:mx.controls.DataGrid = mx.controls.DataGrid(vbox.getChildByName(myDynamicService.layerInfos[layerId].name+"_dg"))
          var attributes:ArrayCollection = datagrid.dataProvider as ArrayCollection;
          
          
          
          var layer:FeatureLayer = new FeatureLayer(myDynamicService.url+"/"+layerId.toString());
           layer.addEventListener(LayerEvent.LOAD, layerLoad_Handler);
          
           Alert.show("test5");
           
           function layerLoad_Handler(event:LayerEvent):void{
            layer.removeEventListener(LayerEvent.LOAD, layerLoad_Handler);
            
            Alert.show("test6");
            
            var objID:String = String(results[0].feature.attributes["Name"]);
            Alert.show(objID);
            
            
            //var str:String = attributes.getItemAt(0)[layer.layerDetails.objectIdField].toString();
            //Alert.show(str);
           }
          
         }
        }
        
        function myFaultFunction(error:Object, clickGraphic:Graphic = null):void
        {
         Alert.show(String(error), "Identify Error");
        }
   }
					
				
			
			
				
			
			
				Solved! Go to Solution.
identifyTask.execute(identifyParams, new AsyncResponder(identResult, identFault));
function identResult(result:IdentifyResult, token:Object = null):void
{
...
}
function identFault(fault:Fault, token:Object = null):void
{
...
}
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		