4 Replies Latest reply on Jun 15, 2009 5:39 AM by DigitalSpeciaist

    set Height of custom component via AS3

    DigitalSpeciaist

      The class below is being used as a custom itemRenderer, and I want to set the height of the VBox to that of its contents (children), or perhaps the easy way would be just set it to 90%. But it must be reset each timethe dataProvider is passed to it.

       

      public class TextDynamicLayout extends VBox
          {
        // .. code removed for brevity

       

      override protected function measure():void
              {           
              super.measure();
               percentHeight = 90; //this is not working as expected
               // measuredHeight = measuredMinHeight = 50;
              }
      }

        • 1. Re: set Height of custom component via AS3
          BennyBeta Level 4

          What about registering a data change listener that calls invalidateSize() (which results in measure() being called)?

          1 person found this helpful
          • 2. Re: set Height of custom component via AS3
            Flex harUI Adobe Employee

            Given that you named the class TextDynamicLayout, it implies you are trying to handle wordwrapping text.  That requires handing down the VBox's explicitWidth to the Text controls before they get measured.  Wordwrapping text can be any size so it needs to have its width fixed in order to determine its height.

             

            The List classes do not support percentages on the renderers.  All renderers are effectively given a size based on the List's size (or DG Column size).  You can see how explicitWidth is handled in the default renderer by looking at the source for ListItemRenderer.as.

             

            Note that VBox or any container makes for heavy and slow rendering.  That's why the default Flex renderers extend UIComponent and have custom measure() and updateDisplayList() methods.

             

            Alex Harui

            Flex SDK Developer

            Adobe Systems Inc.

            Blog: http://blogs.adobe.com/aharui

            • 3. Re: set Height of custom component via AS3
              DigitalSpeciaist Level 1

              I mistakenly chose "Answered." The question has not been answered completely, but I cannot undo that action of choosing "Answered."

               

              Ben, I am not sure how that will solve the problem, could you eexplain a bit more, please?

               

              Flex harUI, You explained the situation precisely as it is in my case. So, is there not a solution to the problem? I really need to vertically and horizontally center the VBox (with its content, and adjust the height and width of the VBox based on the text content).

               

              Look at the image below, the VBox has the grey background and inside the VBox are dynamically rendered textFields with image bullets using the HBox . I know it is best to use the UIComponent for custom itemRenderers, but in my case, there is not really a list of items, just the one you see on Screen, only the text in the VBox changes when the dataProvider changes.

               

              Any suggestions? Thanks.

               

              list_itemRender_img.png

              • 4. Question not answered; still need help
                DigitalSpeciaist Level 1

                Please see my previous post, I still need help with this issue.

                 

                Thanks.