Hi,I'm having an issue with the code below. The issue is that "return name;" is running before "onResult", so it returns null even though the onResult function is getting the correct name. Is there anyway to get it to wait until onResult or onFault are complete?private function getRel(geometry:Geometry,lyr:String):String
{
var name:String;
var query:Query = new Query();
query.geometry = geometry;
var featureLayer:FeatureLayer = map.getLayer(lyr) as FeatureLayer;
featureLayer.queryFeatures(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
if (featureSet.features.length > 0)
{
for each (var myGraphic:Graphic in featureSet.features)
{
if (myGraphic.attributes["NAME"])
{
name = name + myGraphic.attributes["NAME"];
Alert.show("name =" + name);
}
}
}
else
{
//Alert.show("No " + lyr + " found. Please enter " + lyr + " name.");
}
}
function onFault(info:Object, token:Object = null):void
{
//Alert.show(info.faultString + "\n\n" + info.faultDetail, "queryTask fault " + info.faultCode);
}
return name;
}
Cheers,Shannaka