6 Replies Latest reply on Dec 18, 2008 11:39 AM by Gregory Lafrance

    any way to make sure children do not exceed parents width?

    john isaacks Level 1
      Ok say I have 3 children inside an HBox, childA childB and childC. I do not want the HBox to have to scroll horizontally, so if childA resizes to to where the combined width of all three children are wider than the HBox container then childC automatically shrinks?

      is there a way to set this up?
      Thanks
        • 1. Re: any way to make sure children do not exceed parents width?
          -Hob Level 1
          What you're talking about can usually be accomplished by setting each of the children's widths to 100%.

          If that doesn't work, you may have to extend HBox for your specific use case and override the updateDisplayList() method, which is where you would take care of setting the children's widths.
          • 2. Re: any way to make sure children do not exceed parents width?
            john isaacks Level 1
            Thank you for your reply

            "What you're talking about can usually be accomplished by setting each of the children's widths to 100%."

            But this could make the contents stretch wider than the containing HBox and cause a horizontal scrollbar.

            "If that doesn't work, you may have to extend HBox for your specific use case and override the updateDisplayList() method, which is where you would take care of setting the children's widths."

            Thanks I will look into that!
            • 3. Re: any way to make sure children do not exceed parents width?
              Gregory Lafrance Level 6
              This might require more thought. If child A "can" grow in width, and as you say child C "can" shrink in response, then is it possible that A grows so much that C shrinks too much, making it truncated?

              Perhaps some other design would be preferrable, maybe not an HBox but a VBox of something else.
              • 4. Re: any way to make sure children do not exceed parents width?
                john isaacks Level 1
                @Greg I just need to make sure that childA cannot grow so much that is makes childC less than a set (say 50 pixels?) width.

                Here is a function I wrote to do this, it may need some refactoring but its works for now.

                private function leftPanelChange (e:Event):void
                {
                leftPane.width = (leftAccord.selectedChild as ISizeDefaultable).defaultWidth;
                rightPane.width = this.width - 50 - (leftPane.width + centerPane.width);
                if(leftPane.width < 50)
                {
                var excess:Number = 50 - leftPane.width;
                leftPane.width += excess;
                rightPane.width -= excess;
                }
                }
                • 5. Re: any way to make sure children do not exceed parents width?
                  Level 7

                  "john isaacks" <webforumsuser@macromedia.com> wrote in message
                  news:gie53r$mqe$1@forums.macromedia.com...
                  > @Greg I just need to make sure that childA cannot grow so much that is
                  > makes
                  > childC less than a set (say 50 pixels?) width.
                  >
                  > Here is a function I wrote to do this, it may need some refactoring but
                  > its
                  > works for now.
                  >
                  > private function leftPanelChange (e:Event):void
                  > {
                  > leftPane.width = (leftAccord.selectedChild as
                  > ISizeDefaultable).defaultWidth;
                  > rightPane.width = this.width - 50 - (leftPane.width + centerPane.width);
                  > if(leftPane.width < 50)
                  > {
                  > var excess:Number = 50 - leftPane.width;
                  > leftPane.width += excess;
                  > rightPane.width -= excess;
                  > }
                  > }
                  >

                  You may want to look at minWidth and maxWidth.

                  HTH;

                  Amy


                  • 6. Re: any way to make sure children do not exceed parents width?
                    Gregory Lafrance Level 6
                    This might require more thought. If child A "can" grow in width, and as you say child C "can" shrink in response, then is it possible that A grows so much that C shrinks too much, making it truncated?

                    Perhaps some other design would be preferrable, maybe not an HBox but a VBox of something else.