Once you’ve defined the input properties in a Query object you can then use QueryTask to execute the query against a layer. You must provide a pointer to the layer that will be queried. This pointer should be an integer based value. Notice in the code example on this slide that we are pointing to the 6th layer in the ESRI_CENSUS_USA map service. Although the integer shows a value of 5 it is actually the sixth layer since it is a zero based array. In other words, the first layer has an integer value of 0. Execute returns a FeatureSet object that contains the results of the query and these features are processed through a callback function which is specified in the execute( ) method.
In the figure below you’ll see a depiction of how data binding can be used with queries in Flex. Here, the FeatureSet returned by our QueryTask is bound to a Flex grid component. The contents of the grid will automatically be populated with the contents of the FeatureSet without the need for a lot of coding. As you can see from the code snippet, data binding is accomplished through the use of curly braces that surround the data to be bound to the component. Data binding in Flex is specified with these curly braces.