Justin,
I think it is going to have something to do with your zoom code and timing issues. Post the code that you are using in the MapLoadComplete.
Think your right. I read a couple of other posts in more detail and moved the code (the exact same code) into the layerloadComplete event and it now works. Here is the code snippet. if (ExternalInterface.available)
{
var result:URLVariables = new URLVariables();
var urlSubstring:String = ExternalInterface.call("window.location.search.substring", 1);
if (urlSubstring && urlSubstring.length > 0 != "debug=true")
{
result.decode(urlSubstring);
// Parse URL
var qValue:String
if (result["excavationpermit"])
{
qValue = result["excavationpermit"];
var queryTask:QueryTask = new QueryTask();
var query:Query = new Query();
query.returnGeometry = true;
query.where = "order_no = '" + qValue + "'";
queryTask.url = "http://df21pce00255325/ArcGIS/rest/services/Common_Utilities/FeatureServer/0";
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
if (featureSet.features.length == 0)
{
Alert.show("Excavation Permit Not Found. Please Try Again.");
}
else
{
//uninon the sel graphic extents and zoom
var unionExtent:Extent;
var myFirstGraphic:Graphic = featureSet.features[0];
unionExtent = Polygon(myFirstGraphic.geometry).extent;
for each (var myGraphic1:Graphic in featureSet.features)
{
unionExtent = unionExtent.union(Polygon(myGraphic1.geometry).extent);
}
map.extent = unionExtent; // Zoom to queried polygon
map.scale = 250;
// make sure the whole extent is visible
if (!map.extent.contains(unionExtent))
{
map.level--;
}
//turn on required layers
var layers:ArrayCollection = map.layers as ArrayCollection;
for each (var layer:Layer in layers)
{
if (layer.name.toLowerCase() == "imagery")
{
layer.visible = false;
}
else
{
layer.visible = true;
}
}
}
}
function onFault(info:Object, token:Object = null):void {
Alert.show("Excavation Permit Not Found. Please Try Again.");
}
}
}
}