0 Replies Latest reply on Mar 9, 2008 11:01 AM by piercer2

    Textfield Measuring

    piercer2 Level 1
      OK, this questions is all about AS3 and Flex, and the invalidation mechanism.

      I have a custom component (a list item renderer) that includes a textfield. The custom component has percentWidth=100. How do I know what height the textfield is when it comes to the measure method being called.

      As far as I am aware the only time I really know what width I have to draw in is when updateDisplayList is called, but the problem is that that happens after measure has been called. Therefore I end up in a 2 step process (which I haven't got to work yet).

      1) The text field is multi-line, autosize is set to LEFT, and word wrap is true.
      2) In commitProperties I set the text of the textfield
      3) In measure, i don't know how to access the width of the component I want to fit in. I can return a height but it might be wrong.
      4) When updateDisplayList is called i am passed the unscaledWidth. At this point I can set the width of the textfield, but that will change the height, and therefore my itemrenederer does not display properly.

      I am trying to implement a second invalidate size now that we know the width, but this does not seem to work.

      Is there some standard best practive for laying out and measuring the textfield without some convoluted twopass approach?

      Thanks for any help.

      P.S. Is there any way for a child component to know the width of its parent component when it is measuring itself - this would solve the problem.