Select to view content in your preferred language

How to retrieve the feature values

456
2
Jump to solution
06-15-2012 05:50 AM
ShaningYu
Honored Contributor
I used the sample: Zoom to Found Features source code at
http://help.arcgis.com/en/webapi/flex/samples/index.html#/Zoom_to_found_features/01nq0000005n000000/
I want to retrieve the values of the found feature. In this piece of code
private function executeCompleteHandler(event:FindEvent):void {
myGraphicsLayer.clear();
myGraphicsLayer.symbol = sfsFind;

var resultCount:int = event.findResults.length;

if (resultCount == 0) {
Alert.show("No record is found. Please change your search.");
} else {
// add feature as graphic to graphics layer
for (var i:int = 0; i < resultCount; i++) {
var graphic:Graphic = FindResult(event.findResults).feature;
graphic.toolTip = event.findResults.foundFieldName + ": " + event.findResults.value;
myGraphicsLayer.add(graphic);

// Code I added in order to retrive the values of the feature (where STF, COF, ... are the attribute names)
var tempObj:Municipality = new Municipality();
tempObj.STF = event.findResults.STF;
tempObj.COF = event.findResults.COF;
tempObj.MCN = event.findResults.MCN;
tempObj.Type = event.findResults.Type;
tempObj.Area = event.findResults.Area;
......
}
......
}
}
But it does not work. How to revise the code to retrieve the values? Thanks.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Shaning,

   As the result is a graphic you have prefix your calls to attribute values with attributes.

tempObj.STF = event.findResults.attributes.STF;


Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Shaning,

   As the result is a graphic you have prefix your calls to attribute values with attributes.

tempObj.STF = event.findResults.attributes.STF;


Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:
0 Kudos
ShaningYu
Honored Contributor
Great!  Your response made me recall some of my codes made 2 years ago.  Thanks again.
0 Kudos