Select to view content in your preferred language

How not to repeate code for a event that creates a map tool tip

1888
3
Jump to solution
03-29-2012 01:48 PM
ionarawilson1
Deactivated User
I realized my previous thread didnt have an appropriate tile so I am rephrasing everything


I am working on a web map 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 would like to have some help on recoding the code below so I dont have to repeat a thousand times for all the measures I have. Any ideas? (full code and image of the map application are attached).

Below is the code snippet:


public function fLayer_graphicAddHandler(event:GraphicEvent):void
   {
    event.graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
    event.graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
 
   }
  
   public function onMouseOverHandler(event:MouseEvent):void
   {

   
    fLayer.graphicProvider = radioBtnGroup.selectedValue
    
    var htmlText: String = radioBtnGroup.selectedValue.
    
    const htmlText:String = graphic.attributes.htmlText;
    
    
   
    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();
     textArea.width = 150
     textArea.height = 25
     try{
     textArea.htmlText = myURL.selectedItem.labeltext +":" + " "+ 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);
     }
     
    
    
    }
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: rscheitlin

Ionara,

    You are not going to get a lot of takers to spend their time teaching the basics of coding on these forums. But I guess I am not most people.

I can't keep doing this though.

View solution in original post

0 Kudos
3 Replies
by Anonymous User
Not applicable
Original User: rscheitlin

Ionara,

    You are not going to get a lot of takers to spend their time teaching the basics of coding on these forums. But I guess I am not most people.

I can't keep doing this though.
0 Kudos
ionarawilson1
Deactivated User
Thank you so much Robert! You are awesome! I appreciate your helping me ! This will help me learn also!
0 Kudos
by Anonymous User
Not applicable
Original User: ionara_wilson

I appreciate you taking the time to do that! It was going to take me a while to figure it out!
0 Kudos