Select to view content in your preferred language

PopupRenderSkin with radio buttons part 2

2996
12
Jump to solution
10-24-2012 05:00 PM
RhettZufelt
MVP Notable Contributor
I have taken the snippets from here:
http://forums.arcgis.com/threads/47909-PopUpRendererSkin.mxml-with-Radio-Buttons?p=243845&posted=1#p...

and am trying to get a radio button on the bottom of my popup window that turns on/off thier respective label service.
Everything seems to be working fine as far as the radio buttons, but the infoWinClose_Handler is giving me some issues.  It works just fine for the first item/layer clicked on, however, if I get popup info from a "different" layer, I get reference to null object error when I close any other popup window (other than the first one I click on).

Here is what I've gotten so far (well, at least the portions I've added)  I have tried several "if" statements to try to get it to only change visibility if it was one of the "toggle" layers, and ignore the "other" popups so I don't get the null issues, but have had no luck.

I need it to close the layer that was toggled on when the widget is closed.  Would really be nice if it would close the toggled on layer when "switching" to a different layer as well.  This would probalby solve the null issues.

The code that determines which layer to load, toggle on and off, and whether or not to include the toggle buttons is working fine, only the on close function that I'm having issues with.

Any ideas?

R_


 <fx:Script>   <![CDATA[     [Bindable] var RBlabel:String;            // variable used to capture the current (identified) layer name    [Bindable] var RBlayer:String;           //variable used to tell which layer to toggle on/off    [Bindable] var RBonsel:Boolean = false;  // variable used to capture "selected" state of the radio button    [Bindable] var RBoffsel:Boolean = true;  // variable used to capture "selected" state of the radio button     private function skin_preinitializeHandler(event:FlexEvent):void    {     // set the link styles //My Add                      off.visible = false;     on.visible = false;     RBlayer = "";     RBlabel = "";          if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/Buildings/MapServer/3"){      off.visible = true;      on.visible = true;          RBlayer = "Buildings";      RBlabel = "Building Labels";     }     if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/All_Waste_Sites/MapServer/1"){      off.visible = true;      on.visible = true;          RBlayer = "WasteSites";      RBlabel = "Point Labels";     }     if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/All_Waste_Sites/MapServer/2"){      off.visible = true;      on.visible = true;          RBlayer = "WasteSites";      RBlabel = "Line Labels";     }     if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/All_Waste_Sites/MapServer/3"){      off.visible = true;      on.visible = true;          RBlayer = "WasteSites";      RBlabel = "Poly Labels";     } //End My add     textLayoutConfiguration = new Configuration();     var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();     textLayoutFormat.color = getStyle("linkActiveColor")     textLayoutFormat.textDecoration = TextDecoration.UNDERLINE;     textLayoutConfiguration.defaultLinkActiveFormat = textLayoutFormat;      vGroup.addElement(ToggleLayers);   // My Add - this is not where I have it, just wanted to include it somewhere.   //My Add    protected function layerRBgroup_changeHandler(event:Event):void    {     var map:Map = hostComponent.map;     if (event.currentTarget.selectedValue == "on"){          map.getLayer(RBlabel).visible = true;       RBonsel = true;                                                 RBoffsel = false;      }     if (event.currentTarget.selectedValue == "off"){         map.getLayer(RBlabel).visible = false;         RBoffsel = true;                           RBonsel = false;           }    }    private function infoWinClose_Handler(event:Event):void    {            var map:Map = hostComponent.map;      map.getLayer(RBlabel).visible = false;      RBoffsel = true;      RBonsel = false;     }     }    //End My add   ]]>  </fx:Script>   <fx:Declarations>   <!--- @private -->   <s:RadioButtonGroup id="layerRBgroup" change="layerRBgroup_changeHandler(event)" />     <!--- @private -->   <s:HGroup gap="6" verticalAlign="middle" id="ToggleLayers">    <s:RadioButton id="on" value="on" group="{layerRBgroup}" label="Turn Labels On" selected="{RBonsel}" />    <s:RadioButton id="off" value="off" group="{layerRBgroup}" label="Turn Labels Off" selected="{RBoffsel}" />   </s:HGroup>  </fx:Declarations> </s:SparkSkin>
Tags (2)
0 Kudos
12 Replies
RhettZufelt
MVP Notable Contributor
Well, is working for the most part.

It appears as if it is somehow keeping a "list" of feature classes that I have "clicked on" as once I have clicked a feature from the "Buildings" layer, it will never execute the skin_preinitializeHandler event again if I click on any other features from the Buildings layer.  When i click on a feature from a layer the "first" time, it sends it through the preinitializeHandler, any subsequent clicks to "that layer" will not so I don't get my varialbes, etc. set.

Any idea how to "reset" the "list" of pre-clicked features so it goes through my "if" statements each time a feature is clicked?

(or, a better location for my if statements so that they do get evaluated every time I click a feature?)

R_
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Rhett,

   The skin_preinitializeHandler function only gets called at certain times in the code life cycle. If you want something to get evaluated every time something gets clicked than the place to put code is the commitProperties function.
0 Kudos
RhettZufelt
MVP Notable Contributor
Thanks Robert,

That is what I was looking for.

R_
0 Kudos