Solved! Go to Solution.
private var lineSymbol:SimpleLineSymbol = new SimpleLineSymbol("solid", 0x000000); [Bindable] private var noDataSymbol:Symbol = new SimpleFillSymbol("solid", 0x000000, 1.0, lineSymbol); private var IndustryTypeSymbols:Array = [ new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol) ]; private function createIndustryTypeLegend():void { IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[28].color, " Container Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[27].color, " Cooking Wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[26].color, " Dry Kiln")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[25].color, " Engineered Wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[24].color, " Fencing")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[23].color, " Firewood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[22].color, " Gathering Yard")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[21].color, " Hardwood Mat Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[20].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[19].color, " Landscape Organics")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[18].color, " Pallet Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[17].color, " Paper Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[16].color, " Planning Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[15].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[14].color, " Plywood Plant")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[13].color, " Pallet Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[12].color, " Paper Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[11].color, " Planning Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[10].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[9].color, " Plywood Plant")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[8].color, " Posts/Poles/Pilings ")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[7].color, " Preservation wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[6].color, " Re-saw Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[5].color, " Saw Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[4].color, " Secondary Manufacturing")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[3].color, " Shaving Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[2].color, " Timber-Frame Homes")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[1].color, " Veneer")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[0].color, " Wood Pellet Mill")); } import mx.controls.Label; private function createLegendItem(color:uint, text:String):UIComponent { var hbox:HBox = new HBox(); hbox.addChild(createSwatch(color)); var myLabel:mx.controls.Label = new mx.controls.Label(); myLabel.text = text; hbox.addChild(myLabel) return hbox; } private function createSwatch(color:uint):UIComponent { var swatch:UIComponent = new UIComponent(); swatch.graphics.beginFill(color); swatch.graphics.drawCircle(15, 10, 8); swatch.graphics.endFill(); return swatch; }
<mx:TitleWindow id="titleWin2" title="Legend" height="860" mouseDown="titleWin2_mouseDownHandler(event)" mouseUp="titleWin2_mouseUpHandler(event)" showCloseButton="true" verticalScrollPolicy="off" horizontalScrollPolicy="off" visible="false" styleName="titlewindowstyle" color="#000000" close="close()"> <mx:VBox height="850" width="200" > <mx:Spacer height="2" /> <mx:VBox id="IndustryTypeLegend" initialize="createIndustryTypeLegend()"> <mx:Label text="Industry Type" fontWeight="bold" color="#000000" /> </mx:VBox> </mx:VBox> </mx:TitleWindow>
private function runQueryTaskbuffer(geometry:Geometry):void { queryTaskbuffer.url = "http://tfs-24279/ArcGIS/rest/services/ForestProducts/dynamic_layer_forest_products/MapServer/0"; queryTaskbuffer.showBusyCursor = true; queryTaskbuffer.useAMF = false; querybuffer.geometry = geometry; //geometry from the drawToolbar querybuffer.returnGeometry = true; //set to true because we want to place points on the map querybuffer.spatialRelationship = "esriSpatialRelIntersects"; querybuffer.outSpatialReference = myMap.spatialReference; querybuffer.outFields = ['*']; //run the query task queryTaskbuffer.execute(querybuffer, new AsyncResponder( onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { if (featureSet.features.length == 0){ resizableDraggableTitleWindowbuffer.visible = false; resizableDraggableTitleWindowpolygon.visible = false; resizableDraggableTitleWindowintersectingpolygon.visible = false; resizableDraggableTitleWindow.visible = false; resizableDraggableTitleWindowcompanyincounty.visible = false; querydgbuffer.visible = false; info.text = "No matching records found. Please try again."; }else{ myGraphicslayer.clear() querydgbuffer.visible = true; resizableDraggableTitleWindowbuffer.visible = true; myGraphicslayerbuffer.visible = true; querydgbuffer.dataProvider = queryTaskbuffer.executeLastResult.attributes resizableDraggableTitleWindowpolygon.visible = false; resizableDraggableTitleWindowintersectingpolygon.visible = false; resizableDraggableTitleWindow.visible = false; resizableDraggableTitleWindowcompanyincounty.visible = false; for each(var graphic : Graphic in featureSet.features) { graphic.symbol = resultsSymbol; myGraphicslayerbuffer.add(graphic); graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverbuffer); graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutbuffer); if (graphic.attributes.Homepage !== " " || graphic.attributes.Email !==" ") { graphic.addEventListener(MouseEvent.CLICK, clickongraphic) if (graphic.attributes.Homepage !== " " && graphic.attributes.Email !==" ") { graphic.toolTip = "Click for Website or Email link" } if (graphic.attributes.Homepage == " " && graphic.attributes.Email !==" ") { graphic.toolTip = "Click for Email link" } if (graphic.attributes.Homepage !== " " && graphic.attributes.Email ==" ") { graphic.toolTip = "Click for Website link" } } } } if (featureSet.features.length > 1) { info.text = "There are " + featureSet.features.length + " matching records"; } if (featureSet.features.length == 1) { info.text = "There is " + featureSet.features.length + " matching record"; } } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem in the Buffer Search"); } }
<s:Group left="5" bottom="60"> <s:RectangularDropShadow left="0" right="0" top="0" bottom="0" alpha="1" angle="90" blRadius="5" blurX="6" blurY="6" brRadius="5" color="#000000" distance="1" tlRadius="5" trRadius="5"/> <s:Rect left="0" right="0" top="0" bottom="0" radiusX="5" radiusY="5"> <s:fill> <s:SolidColor alpha="0.7" color="0xC5C5C9"/> </s:fill> </s:Rect> <esri:Legend id="legend" layers="{[myGraphicslayerbuffer]}" map="{myMap}" left="5" right="5" top="5" bottom="5"/> </s:Group>
private var lineSymbol:SimpleLineSymbol = new SimpleLineSymbol("solid", 0x000000); [Bindable] private var noDataSymbol:Symbol = new SimpleFillSymbol("solid", 0x000000, 1.0, lineSymbol); private var IndustryTypeSymbols:Array = [ new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol) ]; private function createIndustryTypeLegend():void { IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[28].color, " Container Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[27].color, " Cooking Wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[26].color, " Dry Kiln")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[25].color, " Engineered Wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[24].color, " Fencing")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[23].color, " Firewood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[22].color, " Gathering Yard")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[21].color, " Hardwood Mat Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[20].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[19].color, " Landscape Organics")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[18].color, " Pallet Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[17].color, " Paper Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[16].color, " Planning Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[15].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[14].color, " Plywood Plant")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[13].color, " Pallet Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[12].color, " Paper Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[11].color, " Planning Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[10].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[9].color, " Plywood Plant")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[8].color, " Posts/Poles/Pilings ")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[7].color, " Preservation wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[6].color, " Re-saw Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[5].color, " Saw Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[4].color, " Secondary Manufacturing")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[3].color, " Shaving Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[2].color, " Timber-Frame Homes")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[1].color, " Veneer")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[0].color, " Wood Pellet Mill")); } import mx.controls.Label; private function createLegendItem(color:uint, text:String):UIComponent { var hbox:HBox = new HBox(); hbox.addChild(createSwatch(color)); var myLabel:mx.controls.Label = new mx.controls.Label(); myLabel.text = text; hbox.addChild(myLabel) return hbox; } private function createSwatch(color:uint):UIComponent { var swatch:UIComponent = new UIComponent(); swatch.graphics.beginFill(color); swatch.graphics.drawCircle(15, 10, 8); swatch.graphics.endFill(); return swatch; }
<mx:TitleWindow id="titleWin2" title="Legend" height="860" mouseDown="titleWin2_mouseDownHandler(event)" mouseUp="titleWin2_mouseUpHandler(event)" showCloseButton="true" verticalScrollPolicy="off" horizontalScrollPolicy="off" visible="false" styleName="titlewindowstyle" color="#000000" close="close()"> <mx:VBox height="850" width="200" > <mx:Spacer height="2" /> <mx:VBox id="IndustryTypeLegend" initialize="createIndustryTypeLegend()"> <mx:Label text="Industry Type" fontWeight="bold" color="#000000" /> </mx:VBox> </mx:VBox> </mx:TitleWindow>
Here is the solution:private var lineSymbol:SimpleLineSymbol = new SimpleLineSymbol("solid", 0x000000); [Bindable] private var noDataSymbol:Symbol = new SimpleFillSymbol("solid", 0x000000, 1.0, lineSymbol); private var IndustryTypeSymbols:Array = [ new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xFFFFCC, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0xC2E699, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x78C679, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x31A354, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol), new SimpleFillSymbol("solid", 0x006837, 1.0, lineSymbol) ]; private function createIndustryTypeLegend():void { IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[28].color, " Container Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[27].color, " Cooking Wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[26].color, " Dry Kiln")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[25].color, " Engineered Wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[24].color, " Fencing")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[23].color, " Firewood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[22].color, " Gathering Yard")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[21].color, " Hardwood Mat Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[20].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[19].color, " Landscape Organics")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[18].color, " Pallet Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[17].color, " Paper Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[16].color, " Planning Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[15].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[14].color, " Plywood Plant")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[13].color, " Pallet Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[12].color, " Paper Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[11].color, " Planning Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[10].color, " Import/Export")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[9].color, " Plywood Plant")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[8].color, " Posts/Poles/Pilings ")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[7].color, " Preservation wood")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[6].color, " Re-saw Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[5].color, " Saw Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[4].color, " Secondary Manufacturing")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[3].color, " Shaving Mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[2].color, " Timber-Frame Homes")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[1].color, " Veneer")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[0].color, " Wood Pellet Mill")); } import mx.controls.Label; private function createLegendItem(color:uint, text:String):UIComponent { var hbox:HBox = new HBox(); hbox.addChild(createSwatch(color)); var myLabel:mx.controls.Label = new mx.controls.Label(); myLabel.text = text; hbox.addChild(myLabel) return hbox; } private function createSwatch(color:uint):UIComponent { var swatch:UIComponent = new UIComponent(); swatch.graphics.beginFill(color); swatch.graphics.drawCircle(15, 10, 8); swatch.graphics.endFill(); return swatch; }
And on the mxml<mx:TitleWindow id="titleWin2" title="Legend" height="860" mouseDown="titleWin2_mouseDownHandler(event)" mouseUp="titleWin2_mouseUpHandler(event)" showCloseButton="true" verticalScrollPolicy="off" horizontalScrollPolicy="off" visible="false" styleName="titlewindowstyle" color="#000000" close="close()"> <mx:VBox height="850" width="200" > <mx:Spacer height="2" /> <mx:VBox id="IndustryTypeLegend" initialize="createIndustryTypeLegend()"> <mx:Label text="Industry Type" fontWeight="bold" color="#000000" /> </mx:VBox> </mx:VBox> </mx:TitleWindow>
private var lineSymbol:SimpleLineSymbol = new SimpleLineSymbol("solid", 0x00FF00); private var simplefillsymbol0:SimpleFillSymbol = new SimpleFillSymbol("solid", 0xFF0000, 1.0, lineSymbol); private var simplefillsymbol1:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x0000FF, 1.0, lineSymbol); private var simplefillsymbol2:SimpleFillSymbol = new SimpleFillSymbol("solid", 0xFFA500, 1.0, lineSymbol); private var simplefillsymbol3:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x008000, 1.0, lineSymbol); private var simplefillsymbol4:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x9B30FF, 1.0, lineSymbol); private var simplefillsymbol5:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x292421, 1.0, lineSymbol); private var simplefillsymbol6:SimpleFillSymbol = new SimpleFillSymbol("solid", 0xFF0000, 1.0, lineSymbol); private var simplefillsymbol7:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x0000FF, 1.0, lineSymbol); private var simplefillsymbol8:SimpleFillSymbol = new SimpleFillSymbol("solid", 0xFFA500, 1.0, lineSymbol); private var simplefillsymbol9:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x008000, 1.0, lineSymbol); private var simplefillsymbol10:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x9B30FF, 1.0, lineSymbol); private var simplefillsymbol11:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x292421, 1.0, lineSymbol); private var IndustryTypeSymbols:Array = [ simplefillsymbol0, simplefillsymbol1, simplefillsymbol2, simplefillsymbol3, simplefillsymbol4, simplefillsymbol5, simplefillsymbol6, simplefillsymbol7, simplefillsymbol8, simplefillsymbol9, simplefillsymbol10, simplefillsymbol11 ]; private function createIndustryTypeLegend():void { /* myLegend.layers = [legendlayer]; myLegend.visible = true; */ var label2:mx.controls.Label = new mx.controls.Label label2.text = "Primary Industry"; label2.setStyle("fontWeight", "bold"); IndustryTypeLegend.addChild(label2); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[0].color, " Biomass, wood pellet or landscape organic facility")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[1].color, " Paper mill or chip mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[2].color, " Plywood, veneer, or oriented strandboard mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[3].color, " Post, pole, piling, preservative treating plant")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[4].color, " Sawmill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[5].color, " Other Primary Industry")); var label3:mx.controls.Label = new mx.controls.Label label3.text = "Secondary Industry"; label3.setStyle("fontWeight", "bold"); IndustryTypeLegend.addChild(label3); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[6].color, " Engineered wood product plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[7].color, " Millwork, cabinetry, furniture, or flooring plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[8].color, " Pallet, container or remanufacture plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[9].color, " Panel or wood pellet plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[10].color, " Preservative treating plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[11].color, " Other Secondary Industry")); } import mx.controls.Label; private function createLegendItem(color:uint, text:String):UIComponent { var hbox:HBox = new HBox(); hbox.addChild(createSwatch(color)); var myLabel:mx.controls.Label = new mx.controls.Label(); myLabel.text = text; hbox.addChild(myLabel) return hbox; } private function createSwatch(color:uint):UIComponent { var swatch:UIComponent = new UIComponent(); swatch.graphics.beginFill(color); swatch.graphics.lineStyle(2.5, 0x00FF00, 1); swatch.graphics.drawCircle(15, 10, 8); swatch.graphics.endFill(); return swatch; } private function createLegendItem2(color:uint, text:String):UIComponent { var hbox2:HBox = new HBox(); hbox2.addChild(createSwatch2(color)); var myLabel2:mx.controls.Label = new mx.controls.Label(); myLabel2.text = text; hbox2.addChild(myLabel2) return hbox2; } private function createSwatch2(color:uint):UIComponent { var swatch2:UIComponent = new UIComponent(); swatch2.graphics.beginFill(color); swatch2.graphics.lineStyle(2.5, 0x00FFFF, 1); swatch2.graphics.drawRect(5,2,17,15); swatch2.graphics.endFill(); return swatch2; }
Hi Shabir,
I put the legend in a window popup, but you may put it wherever you want. Can you be more specific when you ask about "implementing" this?private var lineSymbol:SimpleLineSymbol = new SimpleLineSymbol("solid", 0x00FF00); private var simplefillsymbol0:SimpleFillSymbol = new SimpleFillSymbol("solid", 0xFF0000, 1.0, lineSymbol); private var simplefillsymbol1:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x0000FF, 1.0, lineSymbol); private var simplefillsymbol2:SimpleFillSymbol = new SimpleFillSymbol("solid", 0xFFA500, 1.0, lineSymbol); private var simplefillsymbol3:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x008000, 1.0, lineSymbol); private var simplefillsymbol4:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x9B30FF, 1.0, lineSymbol); private var simplefillsymbol5:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x292421, 1.0, lineSymbol); private var simplefillsymbol6:SimpleFillSymbol = new SimpleFillSymbol("solid", 0xFF0000, 1.0, lineSymbol); private var simplefillsymbol7:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x0000FF, 1.0, lineSymbol); private var simplefillsymbol8:SimpleFillSymbol = new SimpleFillSymbol("solid", 0xFFA500, 1.0, lineSymbol); private var simplefillsymbol9:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x008000, 1.0, lineSymbol); private var simplefillsymbol10:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x9B30FF, 1.0, lineSymbol); private var simplefillsymbol11:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x292421, 1.0, lineSymbol); private var IndustryTypeSymbols:Array = [ simplefillsymbol0, simplefillsymbol1, simplefillsymbol2, simplefillsymbol3, simplefillsymbol4, simplefillsymbol5, simplefillsymbol6, simplefillsymbol7, simplefillsymbol8, simplefillsymbol9, simplefillsymbol10, simplefillsymbol11 ]; private function createIndustryTypeLegend():void { /* myLegend.layers = [legendlayer]; myLegend.visible = true; */ var label2:mx.controls.Label = new mx.controls.Label label2.text = "Primary Industry"; label2.setStyle("fontWeight", "bold"); IndustryTypeLegend.addChild(label2); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[0].color, " Biomass, wood pellet or landscape organic facility")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[1].color, " Paper mill or chip mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[2].color, " Plywood, veneer, or oriented strandboard mill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[3].color, " Post, pole, piling, preservative treating plant")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[4].color, " Sawmill")); IndustryTypeLegend.addChild(createLegendItem(IndustryTypeSymbols[5].color, " Other Primary Industry")); var label3:mx.controls.Label = new mx.controls.Label label3.text = "Secondary Industry"; label3.setStyle("fontWeight", "bold"); IndustryTypeLegend.addChild(label3); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[6].color, " Engineered wood product plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[7].color, " Millwork, cabinetry, furniture, or flooring plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[8].color, " Pallet, container or remanufacture plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[9].color, " Panel or wood pellet plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[10].color, " Preservative treating plant")); IndustryTypeLegend.addChild(createLegendItem2(IndustryTypeSymbols[11].color, " Other Secondary Industry")); } import mx.controls.Label; private function createLegendItem(color:uint, text:String):UIComponent { var hbox:HBox = new HBox(); hbox.addChild(createSwatch(color)); var myLabel:mx.controls.Label = new mx.controls.Label(); myLabel.text = text; hbox.addChild(myLabel) return hbox; } private function createSwatch(color:uint):UIComponent { var swatch:UIComponent = new UIComponent(); swatch.graphics.beginFill(color); swatch.graphics.lineStyle(2.5, 0x00FF00, 1); swatch.graphics.drawCircle(15, 10, 8); swatch.graphics.endFill(); return swatch; } private function createLegendItem2(color:uint, text:String):UIComponent { var hbox2:HBox = new HBox(); hbox2.addChild(createSwatch2(color)); var myLabel2:mx.controls.Label = new mx.controls.Label(); myLabel2.text = text; hbox2.addChild(myLabel2) return hbox2; } private function createSwatch2(color:uint):UIComponent { var swatch2:UIComponent = new UIComponent(); swatch2.graphics.beginFill(color); swatch2.graphics.lineStyle(2.5, 0x00FFFF, 1); swatch2.graphics.drawRect(5,2,17,15); swatch2.graphics.endFill(); return swatch2; }