3 Replies Latest reply on Dec 16, 2009 6:54 AM by Gregory Lafrance

    Autosize the container when changing states

    Shivik Level 1

      Hello all

       

      I have created a hierarchy of views like this....

       

      MainPage.mxml

      Sidebar.mxml

      UserPanel.mxml

      LoginPanel.mxml

      MemberMenu.mxml

      SearchPanel.mxml

      NavigationLinksPanel.mxml

      MainContents.mxml

       

      Now I want that when I display an error state in LoginPanel.mxml, the views should be autosized to fit the content. I don't want the scrollbar to appear. Setting the scrollPolicy to off just cuts the content - it doesn't autosize.

       

      Can this be done? Any suggestions anyone?

       

      With best regards

      ShiVik

        • 1. Re: Autosize the container when changing states
          Gregory Lafrance Level 6

          Which container is having its content cutoff?

           

          You have to be careful to set containers to width="100%" (percentWidth=100 in AS) when necessary.

           

          This may not always be possible, because you may have a container that you do not want to expand as much as may be possible with width set to 100%.

           

          But most times when I'm getting unwanted scrollbars I need to set one of the parent containers' width to 100%. The challenge is to figure out which one.

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance
          www.ChikaraDev.com

          Flex Development and Support Services

          1 person found this helpful
          • 2. Re: Autosize the container when changing states
            Shivik Level 1

            Hello there Greg

             

            The container that has its content cut-off is mx:Box. I have based all my components as mx:Box. So I guess I will have to set the width and height to 100% for every container that houses the component. This does work with height also, right?

             

            Thanks and Regards

            ShiVik

            • 3. Re: Autosize the container when changing states
              Gregory Lafrance Level 6

              Yes, it also works for height.

               

              Usually setting width and height to 100% is the way to go, because the containers simply resize to their content, and the UI displays as you have planned. In some case-by-case circumstances you might need to tweak things, such as using Canvas, fixed sizes, etc.

               

              If this post answers your question or helps, please mark it as such.


              Greg Lafrance
              www.ChikaraDev.com

              Flex Development and Support Services

              1 person found this helpful