1 Reply Latest reply on Apr 5, 2009 11:42 PM by K-kOo

    Custom HBox & RawChildren


      Hi everyone,

      I'm working on a AS3 custom HBox component and i'm facing probleme of modelisation. What I am trying to do is to add a Label on the right side of the Box so that when the box is too small and clipping is needed, the label of the Label indicate how much content child remain hidden on the right.

      I have lots of question regarding what should i do to have the cleanest Component Currently I'm extending HBox but I dont really know how could I use a Label outside of the "box", which wouldnt be included into the layout (i tried includeInLayout to false but i believe it doesnt change anything). I saw the rawChildren thing into the Container super class but it's kind of hard to understand how it works without an additionnal explaination...

      Here is what I tried. All what I get is a blank rectangle 120px high and 30px long ...

      public class MoreHBox extends HBox
           protected var more_btn:LinkButton
           public function MoreHBox()
                horizontalScrollPolicy = "off";
                setStyle("borderStyle", "solid");
           override protected function createChildren():void
                if (!more_btn)
                     more_btn = new LinkButton();
                     more_btn.label = "3 mores";
           override protected function measure():void
                measuredWidth = 120;
                measuredHeight = 30;
           override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                super.updateDisplayList(unscaledHeight, unscaledWidth);
                more_btn.move(0, unscaledWidth - more_btn.getExplicitOrMeasuredWidth() - 5);
                trace(unscaledWidth, more_btn.getExplicitOrMeasuredWidth(), unscaledWidth - more_btn.getExplicitOrMeasuredWidth() - 5);


      Anybody could explain me how tu use the rawChildren list.


        • 1. Re: Custom HBox & RawChildren
          K-kOo Level 1

          Ok so managed to fix my (dumb) errors...

          // Previous error : super.updateDisplay List(unscaledHeight, unscaledWidth);
          super.updateDisplay List(unscaledWidth, unscaledHeight);
          // fix : set manually a size to the button
          more_btn.setActualSize(80, 24);
          // previous error : more_btn.move(0, unscaledWidth - more_btn.getExplicitOrMeasuredWidth() - 3);
          more_btn.move(unscaledWidth - more_btn.getExplicitOrMeasuredWidth() - 3, 0);

          But I still have a remaining question :

          Why do we have so set a size to our button ? isn't it supposed to be automatic sizing ?