开发者

Flex wordwrap issue with multiple text instances

开发者 https://www.devze.com 2023-01-01 22:37 出处:网络
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 elem

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 pos开发者_运维问答ition 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号