Skip to main content
Inspiring
August 17, 2009
Question

Unable to calculate text snippet height

  • August 17, 2009
  • 1 reply
  • 761 views

Hello,

I am trying to dinamically adjust the size (height) of a container so a text snippet doesn't move to the next container. In other words I try to make sure that this exact snippet belongs to only one container. The way I try to achieve it is by listening to events which may influence the amount of text which fits the container. For example 'resize' event for the wrapping Sprite (or rather its parent) or 'INLINE_GRAPHIC_STATUS_CHANGED' event for the text flow because images can decrease the space for text. Whenever such events happen I check if the snippet belongs to more than one container and if not I increase the container's height (setting the composition height accordingly as well) and then I call 'compose()'. My expectation is that immediately after calling compose() I would be able to iterate over all TextFlowLines and retrieve the corresponding TextLines out of them. I also expect that all these will be valid and properly positioned/measured because I just called compose(). However some TextFlowLines are not completely populated with all these data. For example textLineExist=false, controller=null and validity='invalid'. This stops me from calculating the exact container's height I need to fit the snippet within this container.

Any information how to achieve this behavior would be greatly appreciated.

Thank you!

This topic has been closed for replies.

1 reply

Inspiring
August 18, 2009

Hello again,

I found a solution to the problem mentioned above.

Instead of calling "compose()" I call "composeToPosition()" i.e. explicitely ask to compose to the very end of the text flow.

Now it works properly and I hope this is the right way to solve it.

Looks like "compose()" tries to be smart and composes text only partially to the point it is needed/visible/whatever.

I haven't examined Adobe's source code though. Hopefully this "solution" is not a workaround which won't work in the next night build.

Anyway if someone can shed some light on this exact behavior it would be great.

Cheers

Adobe Employee
August 19, 2009

HI,

When text is overflowed compose will stop composing as soon as it can.  composeToPosition is exactly what you want.  You found the correct solution.

Regards,

Richard