<esri:ArcGISDynamicMapServiceLayer id="Parcels" url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer"/> var arc:ArcGISDynamicMapServiceLayer = map.getLayer("Parcels") as ArcGISDynamicMapServiceLayer();
My requirement is to define query on featureclass - 1Well the QueryTask allows you to specify the exact layer of the map service that you which to query.
Set the URL to the ArcGIS Server REST resource that represents a single layer or table, e.g. http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5. Note the number "5" at the end of the URL which indicates which specific layer you want to query when querying a map service or a feature service. For an image server, the map service itself is the 'single' layer, so the URL would end with "/MapServer" (without a number).Now if you only want to visually display a particular layer of a map service on the map than setting the layerDefinitions for the ArcGISDynamicMapServiceLayer is the way to go. A featurelayer is a option but this places all the rendering strain on the client machine and is be overkill for your requirement.
myDynamicLayer.layerDefinitions = [null, "NAME = 'ABC'", null];