Skip to main content
Participating Frequently
July 28, 2009
Question

Text measurement in UIComponent

  • July 28, 2009
  • 1 reply
  • 722 views

I’m building a TLF-based component that extends UIComponent in Flex 3.3.

I basically want the component to have the same behavior of am mx:Text component, where the size of the component is whatever the size of the content in the textFlow is (unless an explicitHeight or percentHeight is set).

So in my component I’m calling the setComposition size and updateAllControllers in the updateDisplayList method once I’ve got the unscaledWidth/Height. But what I really want to do is measure the height of the text in measure() and set the measuredHeight there. At the moment I’m doing two passes on updateDisplayList – firstly to set the initial composition size, then going back to measure to set measuredHeight once I can access the getContentBounds() of the composition.

Question is, is there a better way to measure the content before getting to updateDisplayList?

This topic has been closed for replies.

1 reply

Participating Frequently
July 28, 2009

If at measure() time you have an explicitWidth, then you can use that as the compositionWidth and measure the height. But if you have a percentWidth, then you have to wait for the LayoutManager to turn that into an actual number of pixels and pass it to you in updateDisplayList(), then do the second pass.

Gordon Smith

Adobe Flex SDK Team