try this...
private function doQuery():void
{
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
// clear the graphics layer
myGraphicsLayer.clear();
if (featureSet.features.length == 0)
{
Alert.show("No States found. Please try again.");
}
else
{
var myFirstGraphic:Graphic = featureSet.features[0];
MapPoint(myFirstGraphic.geometry).extent;
for each (var myGraphic1:Graphic in featureSet.features)
{
myGraphicsLayer.add(myGraphic1);
}
map.centerAt(myGraphic1.geometry as MapPoint);
map.scale = 18036;
}
}
function onFault(info:Object, token:Object = null):void
{
Alert.show(info.toString());
}
}
]]>
</mx:Script>