var myLayer:FeatureLayer = new FeatureLayer("http://myserver/FeatureServer/0"); pointLayer.mode = "onDemand"; pointLayer.outFields = ["*"]; map.addLayer(myLayer);
var myLayer:FeatureLayer = new FeatureLayer("http://myserver/FeatureServer/0");
pointLayer.mode = "onDemand";
pointLayer.outFields = ["*"];
map.addLayer(myLayer);
And doesn't your url contain arcgis/rest? like this?Simin,
You have a mixture of variable names in your action script code...var myLayer:FeatureLayer = new FeatureLayer("http://myserver/FeatureServer/0"); pointLayer.mode = "onDemand"; pointLayer.outFields = ["*"]; map.addLayer(myLayer);
And doesn't your url contain arcgis/rest? like this?
http://myserver/arcgis/rest/services/FeatureServer/0
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags" initialize="application1_initializeHandler(event)"> <fx:Script> <![CDATA[ import com.esri.ags.layers.FeatureLayer; import mx.events.FlexEvent; protected function application1_initializeHandler(event:FlexEvent):void { // This one doesn't work // var pointLayer:FeatureLayer = new FeatureLayer("http://myserver/ArcGIS/rest/services/Test/FeatureServer/1"); // pointLayer.mode = "onDemond"; // pointLayer.outFields = ["*"]; // map.addLayer(pointLayer); } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <esri:Map id="map"> <!--This one works--> <esri:FeatureLayer id="pointLayer" url="http://myserver/ArcGIS/rest/services/Test/FeatureServer/1" mode="onDemand" outFields="*" /> </esri:Map> </s:Application>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
xmlns:esri="http://www.esri.com/2008/ags"
creationComplete="init()">
<fx:Script>
<![CDATA[
import com.esri.ags.layers.FeatureLayer;
import mx.events.FlexEvent;
protected function init():void{
var pointLayer:FeatureLayer = new FeatureLayer("http://myserver/ArcGIS/rest/services/Test/FeatureServer/1"); pointLayer.mode = "onDemand";
pointLayer.outFields = ['*'];
map.addLayer(pointLayer);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<esri:Map id="map" />
</s:Application>
Simin,
Try this:<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags" creationComplete="init()"> <fx:Script> <![CDATA[ import com.esri.ags.layers.FeatureLayer; import mx.events.FlexEvent; protected function init():void{ var pointLayer:FeatureLayer = new FeatureLayer("http://myserver/ArcGIS/rest/services/Test/FeatureServer/1"); pointLayer.mode = "onDemand"; pointLayer.outFields = ['*']; map.addLayer(pointLayer); } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <esri:Map id="map" /> </s:Application>