Skip to main content
Inspiring
November 4, 2009
Answered

How to detect that a text flow is completely composed and displayed?

  • November 4, 2009
  • 1 reply
  • 824 views

Hello,

I have a text flow (text) which I would like to decorate. For example I would like to add special background and border.

The standard behavior of TLF to add background/borders is not enough in my case.

What is the best event to listen to in order to detect when the text is completely composed and displayed?

Events that may lead to new composition/rendering are resize of the window or changes to the text flow itself so whenever such events happen I would like to be notified once everything is visualized again and then do my decoration on top of the text.

Currently I listen to "UPDATE_COMPLETE" for the canvas which holds the Sprite with the text however I noticed that in some cases on this event when I call textFlow.flowComposer.isDamaged(textFlow.textLength - 1) it returns true.

I guess this is a way to find out if everything is composed and displayed and it looks like sometimes it is not so probably I should use another event.

Thanks,

Smirnoff

This topic has been closed for replies.
Correct answer robin_briggs

The updateComplete event is dispatched when the container has been updated. It should always be true when you get updateComplete that the text in the container is composed and displayed. If there is text in the flow that doesn't fit in the container, that other text may not be composed or displayed. This can happen, for instance, if text text is too big to fit in the container and some has been scrolled out orif the container that was updated was not the last container in the flow.

You can force more of the text to be composed by calling composeToPosition. But if you force it to compose to the end of a very long flow, that could have negative performance implications. You might just want to add your adornments only to the text in the container.

1 reply

robin_briggsCorrect answer
Adobe Employee
November 4, 2009

The updateComplete event is dispatched when the container has been updated. It should always be true when you get updateComplete that the text in the container is composed and displayed. If there is text in the flow that doesn't fit in the container, that other text may not be composed or displayed. This can happen, for instance, if text text is too big to fit in the container and some has been scrolled out orif the container that was updated was not the last container in the flow.

You can force more of the text to be composed by calling composeToPosition. But if you force it to compose to the end of a very long flow, that could have negative performance implications. You might just want to add your adornments only to the text in the container.

Inspiring
November 5, 2009

Thanks for the reply!

Actually the problem I had was fixed when I took the latest night build. I was having problems getting the correct coordinates of a text line when it was supposed to be composed. When I replaced the TLF swc with the latest one the problem disappeared.

Anyway the information you gave me is really helpful because the current approach (listening to updateComplete) must be correct and in case I have similar problems in the future then I'll have one less thing to worry about.