<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:esri="http://www.esri.com/2008/ags"
pageTitle="Editor component with toolbar">
<fx:Script>
<![CDATA[
import mx.events.IndexChangedEvent;
protected function tabNavigator_changeHandler(event:IndexChangedEvent):void
{
switch(event.target.selectedIndex)
{
case 0:
if(areasEditor)
{
// clean up the areasEditor
for each (var featureLayer:FeatureLayer in areasEditor.featureLayers)
{
if (featureLayer.selectedFeatures.length > 0)
{
featureLayer.clearSelection();
}
}
areasEditor.map = null;
areasEditor.featureLayers = null;
areasEditor.drawTool.deactivate();
areasEditor.editTool.deactivate();
areasEditor.templatePicker.clearSelection();
// assign back, if cleaned up
pointsEditor.map = myMap;
pointsEditor.featureLayers = [points];
}
break;
case 1:
if(pointsEditor)
{
// clean up the pointsEditor
for each (var featureLayer1:FeatureLayer in pointsEditor.featureLayers)
{
if (featureLayer1.selectedFeatures.length > 0)
{
featureLayer1.clearSelection();
}
}
pointsEditor.map = null;
pointsEditor.featureLayers = null;
pointsEditor.drawTool.deactivate();
pointsEditor.editTool.deactivate();
pointsEditor.templatePicker.clearSelection();
// assign back, if cleaned up
areasEditor.map = myMap;
areasEditor.featureLayers = [fireAreas];
}
break;
}
}
]]>
</fx:Script>
<mx:HBox height="100%" width="100%">
<mx:TabNavigator id="tabNavigator" width="251" height="347" x="10" y="10" change="tabNavigator_changeHandler(event)"
creationPolicy="auto">
<s:NavigatorContent id="pointsTab" label="Points" width="100%" height="100%">
<esri:Editor id="pointsEditor" height="100%" width="100%" map="{myMap}" toolbarVisible="true" featureLayers="{[points]}"/>
</s:NavigatorContent>
<s:NavigatorContent id="areasTab" label="Areas" width="100%" height="100%" >
<esri:Editor id="areasEditor" height="100%" width="100%" map="{myMap}" toolbarVisible="true" featureLayers="{[fireAreas]}"/>
</s:NavigatorContent>
</mx:TabNavigator>
<esri:Map id="myMap">
<esri:extent>
<esri:Extent id="sheepfire"
xmin="-13144000" ymin="4033000" xmax="-13066000" ymax="4099000">
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
<esri:FeatureLayer id="points"
mode="snapshot"
outFields="*"
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0"/>
<esri:FeatureLayer id="fireAreas"
mode="snapshot"
outFields="*"
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/2"/>
</esri:Map>
</mx:HBox>
</s:Application>