Skip to main content
Known Participant
February 8, 2010
Answered

How to get the exact Height and width of the text in TextLayout Framework

  • February 8, 2010
  • 1 reply
  • 912 views

Hello fellow developers,

I start working with TLF when there is three different SWC's Now I am working with Single SWC with flex 4 and lot of things are changed like

I use calculateHeight(),calculateWidth()  now these methods are not available.

Please if anyone know the replacement of these methods then Let me know.

thanks

This topic has been closed for replies.
Correct answer robin_briggs

If the text exceeds the container, which can happen in a scrollable container where you have to scroll to see some of the text, then the values getContentBounds returns are estimated values. This is because we don't want to force the text to recompose all the way to the end of a very long TextFlow in order to return a value. However, if you want to get the exact amount, and don't mind taking the time to recompose, call textFlow.flowComposer.composeToPosition(), before calling getContentBounds. This forces all the text to recompose to the end, and then getContentBounds will return the fully calculated value instead of estimating.

1 reply

February 8, 2010

You'll want to use getContentBounds() now, then get the width and height from the resulting Rectangle.

Known Participant
February 9, 2010

Thank you Alan for answering , I already use getContentBounds() to get the height ,width but it did not give same dimensions as CalculatedHeight(),CalculateWidth() Method give. getContentBounds() give slightly small Dimensions

Please let me know if any other solution .

robin_briggsCorrect answer
Adobe Employee
February 9, 2010

If the text exceeds the container, which can happen in a scrollable container where you have to scroll to see some of the text, then the values getContentBounds returns are estimated values. This is because we don't want to force the text to recompose all the way to the end of a very long TextFlow in order to return a value. However, if you want to get the exact amount, and don't mind taking the time to recompose, call textFlow.flowComposer.composeToPosition(), before calling getContentBounds. This forces all the text to recompose to the end, and then getContentBounds will return the fully calculated value instead of estimating.