views:

69

answers:

1

Hi,

I have a scenario where I want to dynamically add words of text to a container so that it forms a paragraph of text which is wrapped neatly according to the size of the parent container. Each text element will have differing formatting, and will have differing user interaction options. For example, imagine the text " has just spoken out about ". Each word will be added to the container one at a time, at run time. The username in this case would be bold, and if clicked on will trigger an event. Same with the news article. The rest of the text is just plain text which, when clicked on, would do nothing.

Now, I'm using Flex 3 so I don't have access to the fancy new text formatting tools. I've implemented a solution where the words are plotted onto a canvas, but this means that the words are wrapped at a particular y position (an arbitrary value I've chosen). When the container is resized, the words still wrap at that position which leaves lots of space.

I thought about adding each text element to an Array Collection and using this as a datasource for a Tile List, but Tile Lists don't support variable column widths (in my limited knowledge) so each word would use the same amount of space which isn't ideal.

Does anyone know how I can plot words onto a container so that I can retain formatting, events and word wrapping at paragraph level, even if the container is resized?

A: 

Why aren't you just using a mx:Text component and html text (you can call functions from htmlText), and apply different formatting using html tags.

For information on how to trigger a function from a htmlText field: http://www.adobepress.com/articles/article.asp?p=1019620

quoo
Thanks for the advice. However, I'm not sure how to associate different events with different words in the paragraph? I've added "<a href" tags to my words, but how do I associate one event with one link and another event with another, without setting a generic link on the whole Text element?
Craig Myles
Me again. I found another article which backs up what you are saying and works as another good example in how to use htmlText:http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/Thanks for your help in getting me this far!
Craig Myles
You're welcome, glad you figured the rest out:)
quoo