private function updateBarriers():void {var listItems:ArrayCollection = new ArrayCollection(); //update the statuses as per the lists if (lstDay.dataProvider.length > 0) {listItems.source = lstDay.dataProvider.toArray(); updateBarrierStatuses("Day", listItems);} if (lstNight.dataProvider.length > 0) {listItems.source = lstNight.dataProvider.toArray(); updateBarrierStatuses("Night", listItems); } if (lstVarying.dataProvider.length > 0) {listItems.source = lstVarying.dataProvider.toArray(); updateBarrierStatuses("Varying", listItems);} if (lstBarrierNames.dataProvider.length > 0) {listItems.source = lstBarrierNames.dataProvider.toArray(); updateBarrierStatuses("Not Set", listItems);} doShowAllBarriersQuery(); listItems = null; } private function updateBarrierStatuses(barrierType:String, items:ArrayCollection):void {//create a variable to store the barrier name strings var barrierNames:String = ""; var i:Number = 0; //for the time being we are only working with 4 statuses. This means there is no need to determine id's at runtime //if we need to implement different barrier statuses for different training areas and these need to be retrieved at run //time then this will need to change! var barrierStatus:Number; switch (barrierType) {case "Day": {for(i = 0; i < items.length; i++) {barrierNames = barrierNames + items.toString() + ","; barrierStatus = 1;} break; } case "Night":{ for(i = 0; i < items.length; i++) { barrierNames = barrierNames + items.toString() + ","; barrierStatus = 2;} break;} case "Varying":{ for(i = 0; i < items.length; i++) { barrierNames = barrierNames + items.toString() + ","; barrierStatus = 3;} break;} case "Not Set":{ for(i = 0; i < items.length; i++) { barrierNames = barrierNames + items.toString() + ","; barrierStatus = 4;} break;} } //end switch //remove the last "," from the list barrierNames = barrierNames.substr(0, barrierNames.length - 1); setBarrierStatusesWS(myTrainingAreaName, barrierNames, barrierStatus);} private function setBarrierStatusesWS(trainingArea:String, barrierNames:String, status:Number):void {myWS.updateBarrierStatus(trainingArea, barrierNames, status);} private function doShowAllBarriersQuery() : void {//empty the barrier layer first. gfxBarriers.clear(); //set up a unique renderer to symbolise the barrier layer // ref:http://resources.esri.com/help/9.3/arcgisserver/apis/flex/help/index.html#renderers.htm# var uniqueValuerenderer:UniqueValueRenderer = new UniqueValueRenderer(); uniqueValuerenderer.attribute = "cawdapt_dev.CAWDAPT.Barriers.BARRIER_STATUS_ID"; var uniqueValueInfos:Array =[]; uniqueValueInfos.push(new UniqueValueInfo(daySymbol, "1")); uniqueValueInfos.push(new UniqueValueInfo(nightSymbol, "2")); uniqueValueInfos.push(new UniqueValueInfo(varySymbol, "3")); uniqueValuerenderer.infos = uniqueValueInfos; gfxBarriers.renderer = uniqueValuerenderer; allBarriersQuery.where = " cawdapt_dev.CAWDAPT.Barriers.BARRIER_STATUS_ID <> 4"; queryTask.execute( allBarriersQuery, new AsyncResponder(onResult, onFault )); function onGetBarrierResult( featureSet:FeatureSet, token : Object = null ) : void {var displayFieldName : String = featureSet.displayFieldName; for each ( var myGraphic : Graphic in featureSet.features ) {myGraphic.toolTip = "Barrier: " + myGraphic.attributes["cawdapt_dev.CAWDAPT.Barriers.BARRIER_NAME"] + "." ; gfxBarriers.add( myGraphic );} //zoom to full extent of map: var graphicProvider:ArrayCollection = gfxBarriers.graphicProvider as ArrayCollection; var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(graphicProvider.toArray());} function onGetBarrierFault( info : Object, token : Object = null ) : void {Alert.show( info.toString() );} } <!--Web service results handling:--> <esri:QueryTask id="queryTask" url="http://lmgis02/ArcGIS/rest/services/Barriers/MapServer/0" useAMF="false"/> <esri:Query id="allBarriersQuery" returnGeometry="true"> <esri:outFields> <fx:String>CAWDAPT_DEV.CAWDAPT.BARRIERS.BARRIER_NAME</fx:String> <fx:String>CAWDAPT_DEV.CAWDAPT.BARRIERS.BARRIER_STATUS_ID</fx:String> <fx:String>CAWDAPT_DEV.CAWDAPT.BARRIER_STATUSES.BARRIER_SYMBOL</fx:String> <fx:String>CAWDAPT_DEV.CAWDAPT.BARRIER_STATUSES.SYMBOL_COLOUR</fx:String> </esri:outFields> </esri:Query> <mx:TabNavigator width="100%" height="95%" x="0" y="0"> <mx:Canvas label="Set Barriers" width="100%" height="100%" backgroundColor="#D8D8D8"> <s:VGroup> <mx:HRule width="100%" height="3"/> <s:HGroup id="BarriersGroup"> <s:VGroup> <s:Label id="lblName" text="Barrier Name" toolTip="You can select multiple items by holding CTRL key and clicking, or select a block by holding shift key and clicking"/> <s:List id="lstBarrierNames" dragEnabled="true" dropEnabled="false" allowMultipleSelection="true" dragMoveEnabled="true" dataProvider="{barrierNameArray}" styleName="ListControl" skinClass="Landmarc.customSkins.BarrierListSkin" /> </s:VGroup> <s:VGroup> <s:Label id="lblDay" text="Day" toolTip="Drag and Drop Barriers open during the day into this column"/> <s:List id="lstDay" dragEnabled="true" dropEnabled="true" allowMultipleSelection="true" dragMoveEnabled="true" dataProvider="{new ArrayCollection([])}" styleName="ListControl" skinClass="Landmarc.customSkins.BarrierListSkin"/> </s:VGroup> <s:VGroup> <s:Label id="lblNight" text="Night" toolTip="Drag and Drop Barriers open at night into this column"/> <s:List id="lstNight" dragEnabled="true" dropEnabled="true" allowMultipleSelection="true" dragMoveEnabled="true" dataProvider="{new ArrayCollection([])}" styleName="ListControl" skinClass="Landmarc.customSkins.BarrierListSkin" /> </s:VGroup> <s:VGroup> <s:Label id="lblVary" text="Varying" toolTip="Drag and Drop Barriers open at varying times into this column"/> <s:List id="lstVarying" dragEnabled="true" dropEnabled="true" allowMultipleSelection="true" dragMoveEnabled="true" dataProvider="{new ArrayCollection([])}" styleName="ListControl" skinClass="Landmarc.customSkins.BarrierListSkin"/> </s:VGroup> </s:HGroup> <mx:HRule width="100%" height="3"/> <s:Button label="Save barriers statuses" click="updateBarriers()"/> </s:VGroup> </mx:Canvas>
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.