Hey list,

I'm trying to dynamically create a HSlider and add it as a child in 
the updateDisplayList method of a Canvas subclass.

When I do this, I get a run-time exception because the slider's 
updateDisplayList runs before the slider's commitPropertes (and 
commitProperties seems to set up some internal state that is needed 
by updateDisplayList).

Is this a bug with sliders (I've used this strategy successfully for 
TextInput, ComboBox, etc), or is it just that updateDisplayList isn't 
the proper place to create and add child components?  I don't think I 
can do it in createChildren, as I want to create the Slider based on 
properties that can be set after the Canvas is created.


Simple test case:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="absolute">

<mx:Script>
  <![CDATA[
    import mx.controls.HSlider;

    private var theSlider:HSlider;
    
    override protected function updateDisplayList
(unscaledWidth:Number, unscaledHeight:Number):void
    {
      super.updateDisplayList(unscaledWidth, unscaledHeight);
      
      if (theSlider)
      {
        removeChild(theSlider);
        theSlider = null;
      }
      
      theSlider = new HSlider();
      theSlider.x = 100;
      theSlider.y = 100;
      
      addChild(theSlider);
    }
  ]]>
</mx:Script>

</mx:Application>


Reply via email to