Aww hell yeah! You the man!

Thanks for putting it nice and concise for me. That fixed my issues.
I'll refer to this 'template' in all my custom components... I've been
doing it wrong all over... I'm supprised it "worked" as well as it did!

thanks again,
Thunder

--- In flexcoders@yahoogroups.com, "Michael Schmalle"
<[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> > I'm instantiating new components and calling addChild() as needed
in my
> container component's
> UpdateDisplayList function.
> 
> If I hear you right, no this is not the right place to call add child.
> 
> You should use commitProperties() override to create and add children in
> your component.
> 
> Say,
> 
> someProperty = true; // set somewhere at runtime
> 
> public function set someProperty(value:Boolean):void
> {
>    if (value != _someProperty)
>    {
>       _someProperty = value
>       somePropertyChanged = true;
>       invalidateProperties();
>    }
> }
> 
> 
> override protected function commitProperties():void
> {
>    super.commitProperties();
> 
>    if (somePropertyChanged)
>    {
>       if (mySlider)
>       {
>          removeChild(mySlider);
>       }
> 
>       mySlider = new HSlider();
>       ... set up properties
>       addChild(mySlider); // updateDisplayList() will be called because
> addChild() calls invalidateDisplayList()
>       somePropertyChanged = false;
>    }
> }
> 
> override protected function updateDisplayList(....
> {
>    super.updateDisplayList(...
> 
>    mySlider.move(...
>    mySlider.setActualSize(...
> }
> 
> 
> This is the correct algorithm for creating new children during
runtime if
> properties change that are relvant to the HSlider being added
dynamically at
> runtime.
> 
> Peace, Mike
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On 8/17/06, thunderstumpgesatwork <[EMAIL PROTECTED]> wrote:
> >
> >
> > 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]
> >
> >  
> >
> 
> 
> 
> -- 
> What goes up, does come down.
>







--
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