Hi all,

I'm running into Flex 2 Release error with Slider (HSlider to be
exact). The "null reference exception" happens when there are no
thumbs. See the source and exception traces below.  On line 1480 it
checks the number of thumbs and correctly handles a null 'thumbs'
array. However, if thumbs turns out to be null, or the number of
thumbs is 0, we get the null reference exception on line 1483 (which
doesn't do the same check as was done on 1480).

I'm probably partially at fault for all of this, as I'm trying to
dynamically create instances of components and add them to the UI at
runtime. Is there some precautions that I need to take to ensure
everything is initialized properly? I'm instantiating new components
and calling addChild() as needed in my container component's
UpdateDisplayList function. Does this need to be handled elsewhere?


// -- from Slider.as --
1478: var isHorizontal:Boolean = (_direction ==
SliderDirection.HORIZONTAL);
1479: var numLabels:int = labelObjects ? labelObjects.numChildren : 0;
1480: var numThumbs:int = thumbs ? thumbs.numChildren : 0;
1481: var trackMargin:Number = getStyle("trackMargin");
1482: var widestThumb:Number = 6;
1483: var firstThumb:SliderThumb = SliderThumb(thumbs.getChildAt(0));

// Exception Trace
TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at
mx.controls.sliderClasses::Slider/mx.controls.sliderClasses:Slider::updateDisplayList()[C:\dev\GMC\sdk\frameworks\mx\controls\sliderClasses\Slider.as:1483]
at
mx.core::UIComponent/validateDisplayList()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:5672]
at
mx.managers::LayoutManager/mx.managers:LayoutManager::validateDisplayList()[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:594]
at
mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation()[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:664]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at
mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7789]
at
mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7732]







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to