You could try something like this - it worked for me:actionscript:
public var pointDeleted:Boolean = new Boolean(false);
public var mp:MapPoint = new MapPoint();
protected function graphicClickEvent(event:MouseEvent):void
{
// removes selected graphic
var selGraphic:Graphic = event.currentTarget as Graphic;
myGraphicsLayer.remove(selGraphic);
mp = selGraphic.geometry.extent.center;
// call query for underlying layer
pointDeleted = true;
underlyingLayer_clickHandler(new MapMouseEvent(MapMouseEvent.MAP_CLICK,myMap,mp));
}
protected function underlyingLayer_clickHandler(event:MapMouseEvent):void
{
if (pointDeleted == false){mp = event.mapPoint;}
else{/** keep same mapPoint as first selection */}
myMap.infoWindow.content = popupForm;
queryMapClick.geometry = mp;
underlyingLayer.selectFeatures(queryMapClick); // default selectionMethod is FeatureLayer.SELECTION_NEW
}
protected function underlyingLayer_selectionCompleteHandler(event:FeatureLayerEvent):void
{
// only show infoWindow if a feature was found
if (event.featureLayer.numGraphics > 0){myMap.infoWindow.show(queryMapClick.geometry as MapPoint);}
else{/**Don't do anything if no features are returned by query*/}
}
protected function attrInsp_faultHandler(event:FaultEvent):void
{
Alert.show(event.fault.message, "Fault");
}
This is for the infowindow content for the underlying layer - just an example, use yours insteaddeclarations:
<s:Form id="popupForm">
<s:VGroup id="formVGRP" horizontalAlign="center">
<esri:AttributeInspector id="attrInsp" featureLayers="{[underlyingLayer]}"/>
</s:VGroup>
</s:Form>
<esri:Query id="queryMapClick" />
mxml:
<esri:ArcGISDynamicMapServiceLayer id="underlyingLayerDYN" url="http://140.160.114.190/ArcGIS/rest/services/YourInstance/YourLayer/MapServer"/>
<esri:FeatureLayer id="underlyingLayer"
url="http://140.160.114.190/ArcGIS/rest/services/YourInstance/YourLayer/MapServer/0"
outFields="*"
mode="selection"
selectionColor="0x000000"
selectionComplete="underlyingLayer_selectionCompleteHandler(event)" />
<esri:GraphicsLayer id="myGraphicsLayer" load="addGraphicClickListener()"/>
-Ben