1 Reply Latest reply on Jun 14, 2010 9:43 AM by jsd99

    Creating a custom component with grandchildren

    br7777

      I am having problems creating a custom component that not only contains children but whose children also contain children of their own. I first tried creating the component using mxml which didn't work, then I tried using ActionScript to create a class that extended HGroup which didn't work either. So now I'm trying to create it by extending UIComponent and overwriting the necessary methods like createChildren. I'm not getting a syntax error, but when I try to run the application the progress bar just hangs. When I comment out the code in red below it works fine.

       

      package custom_components
      {
          import mx.core.UIComponent;
          import spark.components.BorderContainer;
          import spark.components.HGroup;
         
          public class Footer3 extends UIComponent
          {
             
              public function Footer3()
              {
                  super();
                  this.bottom = 0;
                  this.left = 0;
                  this.percentWidth = 100;
              }
             
              private var footerBar:HGroup;
              private var footerLinks:BorderContainer;
             
              override protected function createChildren():void
              {
                  super.createChildren();
                 
                  if(footerBar == null)
                  {
                      footerBar = new HGroup();
                      footerBar.percentWidth = 100;
                      footerBar.gap = 0;

       

                     if(footerLinks == null)
                      {
                          footerLinks = new BorderContainer();
                          footerLinks.borderStroke = null;
                          footerLinks.height = 38;
                          footerLinks.percentWidth = 100;
                          footerLinks.styleName = "footerLinks";
                         footerBar.addChild(footerLinks);
                      }

                     
                      addChild(footerBar);
                  }
              }
             
              override protected function measure():void
              {
                  super.measure();
              }
             
              override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
              {
                  super.updateDisplayList(unscaledWidth, unscaledHeight);
              }
          }
      }