Hello. I have a new blog.

I've moved this blog to the following URL Kerkness.ca. Thank you for visiting, please update your bookmarks.

Monday, February 18, 2008

Flex htmlText and Word Wrap

It's a little ridiculous how long it took me to figure this out. I've been trying to layout a block of text in my Flex application and use simple html tags and get word wrapping to display properly. Searching the blogosphere wasn't turning up much solutions. Turns out it's actually rather simple to do but I'm a little surprised no posts or examples anywhere really spells it out.

<mx:Text condenseWhite="true" width="100%">
<mx:htmlText><![CDATA[
This is some<br>
text with simple <b>Html Formatting</b>. And this is a really really
really long line of text which we would want to auto wrap nicely.
]]></mx:htmlText>
</Text>
The important thing in this example is condenseWhite="true" and width="100%". If you don't set condenseWhite to true then Flex will render line breaks and white space. If you don't declare the width then long lines will not automatically wrap.

Believe it or not it took me several hours to figure this out. That probably doesn't say much for my own programming skills. Hopefully this post will save other people from waisting time.

8 comments:

  1. Yay, that did the trick. Thanks!

    ReplyDelete
  2. Hey! this really works! Thanks a million!!!!

    ReplyDelete
  3. Its really awesome tip.Thanks for your help

    ReplyDelete
  4. exactly what i needed.
    Thanx
    bg

    ReplyDelete
  5. It would have taken a long time to figure this out. Thanks for posting this.

    ReplyDelete
  6. YEAH !!! this works! Thanks a lot!!!! there was many stypid examples in the net, that didnt works. But thisone works !!!

    ReplyDelete
  7. Thanks a lot for this this is what I was looking for.

    ReplyDelete

Thank you for the comments.