Skip to main content
Participant
Dec 6, 2009 8:29 PM UTC
Answered

how to determine width/height of the text

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 is closed to new replies. Start a new post to keep the conversation going.
robin_briggsCorrect answer
Adobe Employee
Dec 7, 2009 5:48 AM UTC

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

11 replies

A_Shiyaz
Known Participant
Apr 6, 2010 11:02 AM UTC

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

Translate
Known Participant
Dec 7, 2009 1:41 PM UTC

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

- containerController.compositionWidth

- containerController.compositionHeight

Translate
robin_briggsCorrect answer
Adobe Employee
Dec 7, 2009 5:48 AM UTC

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

Translate
R01andAuthor
Participant
Dec 7, 2009 4:23 PM UTC

Thanks for your help, Robin!

Translate