2 Replies Latest reply on Aug 13, 2008 7:05 AM by MVKVIVEK

    Containers of Container - Resize

    MVKVIVEK
      My application contains one HBox component and HBox has 3 (these numbers are not fixed) VBox as its children. VBox in turn contains Canvas, Button & Label. Something like the following:

      Application
      -->HBox
      ------>VBOX
      ------------> Canvas
      ------------>Button
      ------------>Label
      ------>VBOX
      ------------> Canvas
      ------------>Button
      ------------>Label
      ------>VBOX
      ------------> Canvas
      ------------>Button
      ------------>Label

      On runtime I need to add another copy the same HBox (which has 3 or more VBox) into the Canvas which is inside the VBox. After adding the application will be something like the following


      Application
      -->HBox
      ------>VBOX
      ------------> Canvas
      ---------------------->HBox
      -------------------------->VBOX
      --------------------------------> Canvas
      -------------------------------->Button
      -------------------------------->Label
      -------------------------->VBOX
      --------------------------------> Canvas
      -------------------------------->Button
      -------------------------------->Label
      -------------------------->VBOX
      --------------------------------> Canvas
      -------------------------------->Button
      -------------------------------->Label
      ------------>Button
      ------------>Label
      ------>VBOX
      ------------> Canvas
      ------------>Button
      ------------>Label
      ------>VBOX
      ------------> Canvas
      ------------>Button
      ------------>Label

      Until here is fine.

      I need to resize the canvas depends upon the size of HBox after adding the Vbox Component. The size of the HBox will vary what is there in the VBox.

      Depends on the XML data I need to adding HBox into the Canvas of VBox so I need a logic to built a custom component.

      Please let me know how do I know the width & height of HBox component while I add it to a Canvas so that I can resize the Canvas.

      I hope I explained my query well.

      Thanks
        • 1. Re: Containers of Container - Resize
          Level 7

          "MVKVIVEK" <webforumsuser@macromedia.com> wrote in message
          news:g7rlrf$qn6$1@forums.macromedia.com...
          > My application contains one HBox component and HBox has 3 (these numbers
          > are
          > not fixed) VBox as its children. VBox in turn contains Canvas, Button &
          > Label.
          > Something like the following:
          >
          > Application
          > -->HBox
          > ------>VBOX
          > ------------> Canvas
          > ------------>Button
          > ------------>Label
          > ------>VBOX
          > ------------> Canvas
          > ------------>Button
          > ------------>Label
          > ------>VBOX
          > ------------> Canvas
          > ------------>Button
          > ------------>Label
          >
          > On runtime I need to add another copy the same HBox (which has 3 or more
          > VBox)
          > into the Canvas which is inside the VBox. After adding the application
          > will be
          > something like the following
          >
          >
          > Application
          > -->HBox
          > ------>VBOX
          > ------------> Canvas
          > ---------------------->HBox
          > -------------------------->VBOX
          > --------------------------------> Canvas
          > -------------------------------->Button
          > -------------------------------->Label
          > -------------------------->VBOX
          > --------------------------------> Canvas
          > -------------------------------->Button
          > -------------------------------->Label
          > -------------------------->VBOX
          > --------------------------------> Canvas
          > -------------------------------->Button
          > -------------------------------->Label
          > ------------>Button
          > ------------>Label
          > ------>VBOX
          > ------------> Canvas
          > ------------>Button
          > ------------>Label
          > ------>VBOX
          > ------------> Canvas
          > ------------>Button
          > ------------>Label
          >
          > Until here is fine.
          >
          > I need to resize the canvas depends upon the size of HBox after adding the
          > Vbox Component. The size of the HBox will vary what is there in the VBox.
          >
          > Depends on the XML data I need to adding HBox into the Canvas of VBox so I
          > need a logic to built a custom component.
          >
          > Please let me know how do I know the width & height of HBox component
          > while I
          > add it to a Canvas so that I can resize the Canvas.
          >
          > I hope I explained my query well.

          Containers automatically size themselves around their children. For the
          dynamic insertion of components, look at a repeater.

          HTH;

          Amy


          • 2. Re: Containers of Container - Resize
            MVKVIVEK Level 1
            Thanks for the reply Amy.

            I think I didn't explained well about my requirement. This time I'll try with sample code.

            Please see the attached MXML code

            If you run this application you can see 4 buttons with the first one enabled.

            Clicking on the button "First set" will add an HBox component which contain VBox component (this VBox contains canvas, lable & button). By clicking on the second set I am adding a similar HBox inside the canvas. If you look at the code or run the application you can see what I mean.

            After adding I am getting a scrolling in the Canvas where as I need to resize the canvas and its parents.

            I understand the scrolling is coming becasue I gave the size of the canvas but I need to set the width & height.

            Is it possible to create a custom component for my requirement. If yes please let me know how?

            Thanks.

            Please find the code below,