I need to return the results of buffering several layers, (11 layers possible), around a point (an address). I am looping through the selected layers and executing the query tasks utilizing the QueryEvent.EXECUTE_COMPLETE to determine when to start the next task. Everything works until one of the layers does not have any features in the buffer area. Is there any way to get that info...no features found? onRelation is not called if there are no features found and I can not get to the next layer in the loop. baseDisplay.myGeometryServiceWW.addEventListener(GeometryServiceEvent.RELATION_COMPLETE, onRelation);baseDisplay.myGeometryServiceWW.relation(layerArrayWW, bufferLayerArray, GeometryService.SPATIAL_REL_WITHIN, null); Here is part of the code. (2 of the 11 layers)
private function getBufferResultForFacLayer(layerID:int):void
{ // Start to find the locations/features that are located within the buffer.
[INDENT]bufferLayerArray = new Array();
[/INDENT]
[INDENT]setZoom();
[/INDENT]
[INDENT]//reduce the candidates that can be within the buffer area
[/INDENT]
[INDENT]createLayerQuery(layerID); // create the query and set the outfields for the current layer to be checked
baseDisplay.queryTask.addEventListener(QueryEvent.EXECUTE_COMPLETE, fxnListener);
baseDisplay.queryTask.execute(baseDisplay.queryLayer, new AsyncResponder(onResult, onFault));
layersAdded++;
[/INDENT]
[INDENT]function fxnListener(event:QueryEvent):void
[/INDENT]
[INDENT]{
[/INDENT][INDENT]
[INDENT]bufferLayerArray.push(baseDisplay.bufferLayer.getChildAt(0) as Graphic); // layer contains the point at the center of the buffer area
[/INDENT]
[INDENT]switch (layerID)
{
[INDENT]case 0:
[/INDENT]
[INDENT]
[INDENT]baseDisplay.rhtVBox.lblWW.text = "CAO: 0 location(s) found"; // if no features of layer are found in buffer, onRelation is not called
[/INDENT]
[INDENT]layerArrayCAO = new Array();
for each (var gr0:Graphic in event.featureSet.features)
[INDENT]layerArrayCAO.push(gr0);
[/INDENT]
baseDisplay.queryTask.removeEventListener(QueryEvent.EXECUTE_COMPLETE, fxnListener);
baseDisplay.myGeometryServiceCAO.addEventListener(GeometryServiceEvent.RELATION_COMPLETE, onRelation);
baseDisplay.myGeometryServiceCAO.relation(layerArrayCAO, bufferLayerArray, GeometryService.SPATIAL_REL_WITHIN, null);
break;
[/INDENT]case 1:
[INDENT]baseDisplay.rhtVBox.lblWW.text = "WW: 0 location(s) found";
[/INDENT]
[INDENT]layerArrayWW = new Array();
for each (var gr1:Graphic in event.featureSet.features)
[INDENT]layerArrayWW.push(gr1);
[/INDENT]
baseDisplay.queryTask.removeEventListener(QueryEvent.EXECUTE_COMPLETE, fxnListener);
baseDisplay.myGeometryServiceWW.addEventListener(GeometryServiceEvent.RELATION_COMPLETE, onRelation);
baseDisplay.myGeometryServiceWW.relation(layerArrayWW, bufferLayerArray, GeometryService.SPATIAL_REL_WITHIN, null);
break;
[/INDENT]}
[/INDENT][/INDENT]}
[/INDENT]
[INDENT]function onResult(featureSet:FeatureSet, token:Object = null):void
[/INDENT]
[INDENT]{
}
[/INDENT]
[INDENT]function OnRelation(event:GeometryServiceEvent):void
[/INDENT]
[INDENT]{
[INDENT]// problem: if there are no locations found in the buffer, this function is not reached
[/INDENT]
[INDENT]var facObject:Object;
var obj:Object;
var graphic:Graphic;
[/INDENT][INDENT]if (baseDisplay.provBufferLayer == null)
[INDENT][INDENT]baseDisplay.provBufferLayer = new GraphicsLayer();
[/INDENT][/INDENT]
[INDENT][/INDENT][/INDENT]
[INDENT]switch (layerID)
[/INDENT]
[INDENT]{ // each layer different outfields
[INDENT]case 0:
[/INDENT]
[INDENT]
[INDENT]baseDisplay.myGeometryServiceCAO.removeEventListener(GeometryServiceEvent.RELATION_COMPLETE, onRelation);
[/INDENT]
[/INDENT][INDENT][INDENT]baseDisplay.rhtVBox.lblCAO.text = "CAO: " + event.relations.length + " location(s) found";
for each (obj in event.relations)
{
[INDENT]graphic = new Graphic();
graphic = obj.graphic1;
facObject = new Object();
facObject = {column1: ": ", column2: ": " , column3:??????, column4:"" };
bufferResults.addItem(facObject);
[/INDENT]}
break;
case 1:
[INDENT]
[INDENT]baseDisplay.myGeometryServiceCAO.removeEventListener(GeometryServiceEvent.RELATION_COMPLETE, onRelation);
[/INDENT]
[/INDENT][INDENT]baseDisplay.rhtVBox.lblCAO.text = "CAO: " + event.relations.length + " location(s) found";
for each (obj in event.relations)
{
[INDENT]graphic = new Graphic();
graphic = obj.graphic1;
facObject = new Object();
facObject = {column1: ": ", column2: ": " , column3:??????, column4:"" };
bufferResults.addItem(facObject);
[/INDENT]}
break;
[/INDENT]
[/INDENT][/INDENT][/INDENT][/INDENT]}}}