Skip to main content
Participant
December 6, 2009
Answered

how to determine width/height of the text

  • December 6, 2009
  • 3 replies
  • 2757 views

Hi.

I've created text layout format and text flow.

Now I need to determine width/height of the container so it is exactly fit the text.

Is it possible to get width/height of the text before creating container controller?

Thanks.

This topic has been closed for replies.
Correct answer robin_briggs

It depends on what effect you are trying to get. If you want the text to extend out and not wrap, you can set the width and height to "NaN". To get the actual width and height that was used, you call getContentBounds(). But if you wanted the text to wrap, you have to pick a width to wrap to, and then get the height given the width that was used. So this latter case to work, you could create a controller with a width you specify, but leave the height as "NaN".

- robin

3 replies

A_Shiyaz
Known Participant
April 6, 2010

Thanks a lot Robin for the very useful pointer on using NaN for free flowing text height, as in Flex containers

And, thanks to you and Alexander for the insights into the alternate method with secondary container... very useful.

This post http://forums.adobe.com/message/2630157 gives a good implementation.

Warm Regards,

Shiyaz

Known Participant
December 7, 2009

you can get the width height by reading the ContainerControllers propertys:

- containerController.compositionWidth

- containerController.compositionHeight

robin_briggsCorrect answer
Adobe Employee
December 7, 2009

It depends on what effect you are trying to get. If you want the text to extend out and not wrap, you can set the width and height to "NaN". To get the actual width and height that was used, you call getContentBounds(). But if you wanted the text to wrap, you have to pick a width to wrap to, and then get the height given the width that was used. So this latter case to work, you could create a controller with a width you specify, but leave the height as "NaN".

- robin

R01andAuthor
Participant
December 7, 2009

Thanks for your help, Robin!