private function FilterAttributeTablesByPolygon(poly:Polygon, strURL:String):void { querytaskFeaturesByPolygon.url = strURL; queryFeaturesByPolygon.geometry = poly; querytaskFeaturesByPolygon.execute(queryFeaturesByPolygon); } protected function querytaskFeaturesByPolygon_executeCompleteHandler(event:QueryEvent):void { // highlight the selected features - NOT DONE var fs:FeatureSet = event.featureSet; var attributes:Array = fs.attributes; var al:ArrayList = new ArrayList(); for each (var objRec in attributes) { al.addItem(objRec); } //code continues....
Solved! Go to Solution.
private function FilterAttributeTablesByPolygon(poly:Polygon, strURL:String, callBackFunction:Function):void { var querytaskFeaturesByPolygon:QueryTask = new QueryTask(); querytaskFeaturesByPolygon.url = strURL; var queryFeaturesByPolygon:Query = new Query(); queryFeaturesByPolygon.geometry = poly; querytaskFeaturesByPolygon.execute(queryFeaturesByPolygon, new AsyncResponder(callBackFunction, faultFunction); } private function testquery() { //FIRST CALL FilterAttributeTablesByPolygon(new Polygon(),"http://......", function(event:QueryEvent):void { var fs:FeatureSet = event.featureSet; //......Handle results here //SECOND CALL Called once first is completed... FilterAttributeTablesByPolygon(new Polygon(),"http://......", function(event:QueryEvent):void { var fs2:FeatureSet = event.featureSet; //......Handle results here }); }); }
var iCallId:int = 0; var responderToken:Object = { callId : iCallId++ }; var asyncToken:AsyncToken = configService.send(); asyncToken.addResponder(new AsyncResponder(configResult, configFault, responderToken));
private function FilterAttributeTablesByPolygon(poly:Polygon, strURL:String):void { var token:Object = new Object(); // set the token to the URL of the feature layer to know witch feature layer is being queried when the result is returned token = strURL; querytaskFeaturesByPolygon.url = strURL; queryFeaturesByPolygon.geometry = poly; // pass the token in the responder querytaskFeaturesByPolygon.execute(queryFeaturesByPolygon, new AsyncResponder(querytaskFeaturesByPolygon_executeCompleteHandler, querytask_faultHandler, token)); }
protected function querytaskFeaturesByPolygon_executeCompleteHandler(fs:FeatureSet, token:Object = null):void { var attributes:Array = fs.attributes; var al:ArrayList = new ArrayList(); for each (var objRec in attributes) { al.addItem(objRec); } // use the token value in a switch statement switch(token) { ....Code continues....