2 Replies Latest reply on Aug 5, 2009 3:06 PM by MackrorySD

    Anyway to highlight a particular word in text?

    MackrorySD Level 1

      I'm trying to implement some necessary features using htmlText (http://livedocs.adobe.com/flex/3/html/help.html?content=textcontrols_04.html). One thing I need to do is highlight a particular word in a sentence. Something along the lines of


      This is a sentence with a <highlight> highlighted </highlight> word.


      None of the tags in the aforementioned list seem to be able to be able to do anything like this. I was hoping for a backgroundColor attribute in the font tag, or something. I've also looked at the CSS capabilities, etc... and simply using setStyle("backgroundColor" ...) wouldn't do any good, as I need to highlight only one word.


      It seems we'll just have to find another way to emphasize the text in question, but before I abandon all hope, am I missing anything?

        • 1. Re: Anyway to highlight a particular word in text?
          Gregory Lafrance Level 6

          I think you already know this, but you can change the color of the text with <font color=""> and/or make it bold with <b>, and I think you can make it italic with <i> or <em>.


          Like I said, I think you already knew that but thought I'd mention it.


          You could use the drawing API to draw a rectangle under the word, but with different fonts and font sizes that would be difficult to get right and consistent.


          If this post answered your question or helped, please mark it as such.

          1 person found this helpful
          • 2. Re: Anyway to highlight a particular word in text?
            MackrorySD Level 1

            Yeah, I know about that, already. Problem is, there are several different reasons why a word might get highlighted, and we're already italicizing and bold-ing words for other reasons. That's why we had planned to highlight using a background color.


            Someone did suggest drawing a box and placing it under the word, but you're right - that would be horribly complex as the font is determined pretty much at runtime, and our layout manager has already been made chaotic!


            Thanks, though