2 Replies Latest reply on May 1, 2009 2:30 PM by peteandrus

    resizeToContent?

    peteandrus Level 1

      i have an Accordion with a Tree object inside it. When the tree opens fully, it's taller than the height of the Accordion window. I'd like that to change.

       

      I tried setting resizeToContent=true, but it does nothing. No matter if I set it to true or false, when the content gets too tall, it only gives me a scroll bar on the right, but the window itself does not resize. Shouldn't the window expand if this is set to true? am i missing something? thanks!

        • 1. Re: resizeToContent?
          m_hartnett Level 3

          The resize to content needs to know the height of the object that is in it.

          Since the tree is dyamically sized the Accordion does not know what the height is and assumes it is the size it was originally sized at.

           

          To get around that I have added a handler to the itemOpen and itemClose events like the following:

           

          <mx:Tree id="tree1" labelField="@label" showRoot="true" width="195" x="3" y="2" itemClose="resizeItem(event)" itemOpen="resizeItem(event)">

           

          Then add the method that does the resizing of the tree:

           

          public function resizeItem(e:Event) :void {

               //Get the height of the items in the tree

               var h:int = tree1.measureHeightOfItems();

           

               //Make sure it is a minimum size ... not necessary but good for the look and feel

               if(h < 50) h=50;

           

               //Set the tree height to the height plus add 20 for a little extra space.

               tree1.height = h + 20

           

          }

           

              

          • 2. Re: resizeToContent?
            peteandrus Level 1

            thanks Mark, i'll give that a shot.

             

            i sure hope that's the answer because if it is, this is exactly how i was going to go about tackling it if i got no satisfactory response. that means my Flex problem-solving is advancing! =)

             

            i'll let you know on monday. THANKS