5 Replies Latest reply on Dec 26, 2008 8:19 PM by Newsgroup_User

    HBox child dynamic size.

    jose3
      Hi guys,

      Scenario:
      From an HTTPService connection to PHP I receive an array of buttons and populate custom buttons into an HBox using at least one spacer in the middle. As the HBox size changes I cannot define a default size for the buttons.

      Information I have:
      Amount of buttons (including spacers), HBox width, and HBox height.

      Problem:
      I want to set the buttons to the correct size in order to fit in all the HBox horizontally but I cannot do it correctly. I have tryed btWidth = (HBoxWidth/TotalButtons), however either there is a gap after the last button or the last button goes out of the box.

      I have seen around that I can use minWidth property however I cannot make it work correctly, don't know if I have to set that property in all buttons or just in the one before the last.

      Any help woud be appreciated,
      Thanks lot!!

      Jose
        • 1. Re: HBox child dynamic size.
          Madhav Subedi Level 4
          you should probably think about horizontalGap property of the HBox while doing calculations.
          • 2. HBox child dynamic size.
            jose3 Level 1
            Hi subedimadhav,
            It is an issue cause the default distance between childs in a H-VBox is 8 pixels, I needed to set it to -3 in order to put the chils closer together. That is the more decent solution I have reached so far.

            Less of a problem would be to create a Canvas and render the buttons with a for(), however I need to use the Box.

            Any other suggestion?

            Thanks for the answer,
            Jose
            • 3. Re: HBox child dynamic size.
              Level 7

              "jose3" <webforumsuser@macromedia.com> wrote in message
              news:gj2o8f$mqr$1@forums.macromedia.com...
              > Hi subedimadhav,
              > It is an issue cause the default distance between childs in a H-VBox is 8
              > pixels, I needed to set it to -3 in order to put the chils closer
              > together.
              > That is the closest approach I have reached.
              >
              > Any other suggestion?
              >
              > Thanks for the answer,
              > Jose

              Set all components in the HBox to be 100% width


              • 4. Re: HBox child dynamic size.
                jose3 Level 1
                Yes Amy that did it !!!

                I was really complicating things and missed the simplest solution to let Flex do the job for me.

                Thanks very much,
                Jose
                • 5. Re: HBox child dynamic size.
                  Level 7

                  "jose3" <webforumsuser@macromedia.com> wrote in message
                  news:gj3np6$12n$1@forums.macromedia.com...
                  > Yes Amy that did it !!!
                  >
                  > I was really complicating things and missed the simplest solution to let
                  > Flex do the job for me.

                  You're welcome :-). I think that capability is why they call it "Flex."
                  It's one of the reasons I prefer it to Flash.