<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>Solved! Go to Solution.
attachmentInspector.addEventListener(AttachmentMouseEvent.ATTACHMENT_CLICK, attachmentInspector_attachmentClickHandler);
hostComponent.parent.parent.parent.parent.addEventListener("close", infoWinClose_Handler);
}
private function attachmentInspector_attachmentClickHandler(event:AttachmentMouseEvent):void private function infoWinClose_Handler(event:Event):void
{
hostComponent.parent.parent.parent.parent.removeEventListener("close", infoWinClose_Handler)
var map:Map = hostComponent.map;
var lyr:Layer = map.getLayer(RBlabel);
if(lyr){
lyr.visible = false;
}
RBoffsel = true;
RBonsel = false;
}
private function skin_preinitializeHandler(event:FlexEvent):void
{
// set the link styles
if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/Buildings2/MapServer/0"){
RBlayer = "Buildings";
RBlabel = "Building Labels";
}TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.esri.ags.skins::PopUpRendererSkin/skin_preinitializeHandler()at com.esri.ags.skins::PopUpRendererSkin/___PopUpRendererSkin_SparkSkin1_preinitialize() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.core::UIComponent/initialize() at com.esri.ags.skins::PopUpRendererSkin/initialize() at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded() at mx.core::UIComponent/addChild() at spark.components.supportClasses::SkinnableComponent/attachSkin() at spark.components.supportClasses::SkinnableComponent/validateSkinChange() at spark.components.supportClasses::SkinnableComponent/createChildren() at mx.core::UIComponent/initialize() at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded() at mx.core::UIComponent/addChildAt() at spark.components::Group/addDisplayObjectToDisplayList() at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded() at spark.components::Group/addElementAt() at spark.components::Group/addElement() at com.esri.ags.components::ContentNavigator/commitProperties() at mx.core::UIComponent/validateProperties() at mx.managers::LayoutManager/validateProperties() at mx.managers::LayoutManager/doPhasedInstantiation() at mx.managers::LayoutManager/doPhasedInstantiationCallback()
Rhett,
It is simple the reason you are getting a null is that the hostComponent.featureLayer is null and this evaluate the url of the featurelayer if the featurelayer is null.
private function skin_preinitializeHandler(event:FlexEvent):void
{
// set the link styles
if (hostComponent.featureLayer.url != null){
if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/Buildings2/MapServer/0"){
RBlayer = "Buildings";
RBlabel = "Building Labels";
}
}if(hostComponent.featureLayer){
//do something
}