Select to view content in your preferred language

WMSLooping Widget builds in 3.6 but has a runtime error

2866
3
Jump to solution
02-04-2014 03:53 PM
NeoGeo
by
Frequent Contributor
I built the WMSLooping Widget code which worked fine in the 3.0 Flex Viewer in 3.6 and it built without errors, but once the widget loads in the viewer, it is causing a runtime error in the TOC.  The radar feed actually still works so I was just wondering if anyone had run into this already.

The error is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.esri.viewer.components.toc.tocClasses::TocMapLayerItem/createChildren()
at com.esri.viewer.components.toc.tocClasses::TocMapLayerItem/getLegendResult()
at mx.rpc::AsyncResponder/result()
at com.esri.ags.layers::WMSLayer/layerLegendInfosHandler()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()
at mx.core::UIComponent/callLaterDispatcher()



TocMapLayerItem.as line 472 looks like this:
if (wmsVisibleLayers.source.indexOf(wmsLayerInfo.name) !== -1)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
NeoGeo,

   To fix this you need to update this code in the widget:

        protected function configLoaded(event:Event):void         {             m_cfg = configXML;              m_loopTimer = new Timer( m_cfg.timerMsPerLayer.valueOf() );             m_loopTimer.addEventListener( TimerEvent.TIMER, onTimerTick );                          // Construct list of cycling layers             var aLyrs:XMLList = m_cfg.layersToRotate.layer;             m_aVisLyrs = new ArrayList();              m_aOffsetMins = new ArrayList();                          for each ( var xmlLayer:XML in aLyrs ) {                 m_aVisLyrs.addItem( xmlLayer.text().toString() );                 m_aOffsetMins.addItem( Number(xmlLayer.attribute( "offsetMins" ).valueOf()) );             }                          // Set startup state as paused or running depending on config file contents             currentState = m_cfg.startUpState.valueOf().toString();                          wmsLyr.visibleLayers = m_aVisLyrs;             map.addLayer( wmsLyr );         }          protected function onOpen(event:Event):void         {             if(m_cfg){                 wmsLyr.visibleLayers = m_aVisLyrs;                 map.addLayer( wmsLyr );             }         }


The issue was that the layer was being added to the map before the config was loaded and the visible layers were not set yet.

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
NeoGeo,

   To fix this you need to update this code in the widget:

        protected function configLoaded(event:Event):void         {             m_cfg = configXML;              m_loopTimer = new Timer( m_cfg.timerMsPerLayer.valueOf() );             m_loopTimer.addEventListener( TimerEvent.TIMER, onTimerTick );                          // Construct list of cycling layers             var aLyrs:XMLList = m_cfg.layersToRotate.layer;             m_aVisLyrs = new ArrayList();              m_aOffsetMins = new ArrayList();                          for each ( var xmlLayer:XML in aLyrs ) {                 m_aVisLyrs.addItem( xmlLayer.text().toString() );                 m_aOffsetMins.addItem( Number(xmlLayer.attribute( "offsetMins" ).valueOf()) );             }                          // Set startup state as paused or running depending on config file contents             currentState = m_cfg.startUpState.valueOf().toString();                          wmsLyr.visibleLayers = m_aVisLyrs;             map.addLayer( wmsLyr );         }          protected function onOpen(event:Event):void         {             if(m_cfg){                 wmsLyr.visibleLayers = m_aVisLyrs;                 map.addLayer( wmsLyr );             }         }


The issue was that the layer was being added to the map before the config was loaded and the visible layers were not set yet.
0 Kudos
NeoGeo
by
Frequent Contributor
Thank you for both the answer and the explanation!  You are a blessing!
0 Kudos
MarkDeaton
Esri Alum
Apologies all for being so slow to update the widget. It's fixed per Robert's guidance--thanks!
Updated source and binary versions are now on the widget page:
http://www.arcgis.com/home/item.html?id=75d3bf48976c44ef986a70e0dcad0f75
0 Kudos