The order of the fields shown in the Search and Query widgets is undetermined if you return all the fields using all="true" and you're not using ArcGIS Server 10.
if (featureSet.fields) // requires ArcGIS Server 10.0+ { for each (var field:Field in featureSet.fields) { if (field.name in graphic.attributes) { displayFields(field.name, getFieldXML(field.name), field); } } } else { for (var fieldName:String in graphic.attributes) { displayFields(fieldName, getFieldXML(fieldName), null); } }
No, you'd still need to either hard-code or use LayerDetails.fields to pull out the attributes in a particular order. The Search and Query Widgets are taking advantage of the fields returned as part of the FeatureSet from ArcGIS Server 10. Here's the code from QueryWidget:if (featureSet.fields) // requires ArcGIS Server 10.0+ { for each (var field:Field in featureSet.fields) { if (field.name in graphic.attributes) { displayFields(field.name, getFieldXML(field.name), field); } } } else { for (var fieldName:String in graphic.attributes) { displayFields(fieldName, getFieldXML(fieldName), null); } }
The underlying problem is that when you use for..in statements to pull out all the values from an Object, ActionScript doesn't guarantee any order.
Reference:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/statements.html#for..in
I understand what you say about looping through dynamic object properties, but when I look at a feature within an IdentiftResult the attributes are all in a seemingly random order before I do any for..in statements?
So in short (for my boss), IdentifyResult.Feature.Attributes are always going to be in a random order until we move to ArcGIS Server 10?
What are you using to "look at a feature"?
This is not changed by AGS 10 since the attributes are still in an object. You can use LayerDetails to get the fields of the layer and loop through them in that order like the code above in the QueryWidget.
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/supportClasses/LayerDetails.html