Select to view content in your preferred language

Looping through an array to get the index for each measure in a combo box

969
1
03-29-2012 06:57 AM
ionarawilson1
Deactivated User
Hi folks,

I am working on a web application that has two combo boxes, one for year (called yearcombo) and for measures (called myURL) for that selected year, and also two radiobuttons (in radioBtnGroup). I have two years and a bunch of measure for each year. I  have a map tool tip that when you mouse over the county you see a measure for that specific year. However I have a bunch of measures for each year and I want to be able to loop through the measures (which are in an array collection inside a combobox) so my "if" expression can find every selectedIndex and bring me the tool tip for that selected measure for that selected radio button. Right now I would have to create if statements for each measure (each selectedIndex inside the myURL combobox)and each radiobutton (inside the radioBtnGroup) instead of creating a if expression to get a map tip tool for each measure. I know I would have to create a loop to search for these indexes and enter that in the if expression and also change the graphic.attributes to reflect the right measure or index selected. Do you API for Flex wizards  can give me any tips on how to code this according to my code below ? Any  help is greatly appreciated! (the print scree is attached)[ATTACH=CONFIG]13106[/ATTACH]


Below is the code snippet:


if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
    {
     fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
    
     var graphic:Graphic = Graphic(event.currentTarget);
     graphic.symbol = mouseOverSymbol;
     var htmlText:String = graphic.attributes.htmlText;
     var textArea:TextArea = new TextArea();
    
     try{
     textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
     myMap.infoWindow.content=textArea
     myMap.infoWindow.label = graphic.attributes.NAME;
     myMap.infoWindow.closeButtonVisible = false;
     myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
    
     catch(error:Error) {
      trace("Caught Error: "+error);
     }
     
     


And below is the combo boxes with the arrays

<mx:FormItem label="Year        :"  >
      <mx:ComboBox   id="yearcombo" selectedIndex="0" labelField="label" width="100%" change="changeEvt(event)"  >
       <mx:ArrayCollection id="year"  >
       
      
        <fx:Object label="2007"  year="2007" />
        <fx:Object label="2009"  year="2009" />
       
       
       </mx:ArrayCollection>
      
      
      </mx:ComboBox>
     
     </mx:FormItem>
    
     <mx:FormItem label="Measure:">
      <mx:ComboBox   id="myURL" selectedIndex="8" width="80%" mouseOver="clickEv2(event)" close="closeHandler(event)">
      <mx:ArrayCollection id="measures"   >
      
     
       <fx:Object id="forindout07" labeltext="2007 Forestry Industry Output" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_07_forest_industry_output" year="2007"  />
       <fx:Object id="foremp07" label="2007 Forestry Employment " value="RADIO_BUTTONS/TFEI_07_forest_employment" year="2007" />
       <fx:Object id="forlabinc07" label="2007 Forestry Labor Income " value="RADIO_BUTTONS/TFEI_07_forest_labincome" year="2007" />
       <fx:Object id="forindbustax07" label="2007 Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_07_forest_business_tax" year="2007" />
       <fx:Object id="forindout09" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_09_forest_industry_output" year="2009"  />
       <fx:Object id="foremp09" label="2009 Forestry Employment " value="RADIO_BUTTONS/TFEI_09_forest_employment" year="2009" />
       <fx:Object id="forlabinc09" label="2009 Forestry Labor Income " value="RADIO_BUTTONS/TFEI_09_forest_labincome" year="2009" />
       <fx:Object id="forindbustax09" label="2009 Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_09_forest_business_tax" year="2009" />
       <fx:Object id="blank" label=" "  />
      </mx:ArrayCollection>
Tags (2)
0 Kudos
1 Reply
ionarawilson1
Deactivated User
I am including the entire code (please see attached)
0 Kudos