Frederico,

I did try it. I used the highlighter on a custom item renderer. looks good on 
initial display but when you try scrolling the list component, the display 
screws up. the rectangular "box" used as background doesnt "flow" with the 
text. something to do with relative x,y positioning. looks like it was not 
designed to be used for renderers.

Frederico Garcia <[EMAIL PROTECTED]> wrote:                             ibo 
escreveu:
 > Have anyone worked on something like this before? What I want is to 
 > highlight the word by changing the background color of each keyword 
 > from a sentence/paragraph.
 >
 > Here is my code so far:
 >
 >           private function applyTextHighlight(textField:UIComponent, 
 > listOfWordPositions:Array):void {
 >                var textArea:TextArea = TextArea(textField);
 >                var tr:TextRange = new TextRange(textArea);
 >               
 >                tr.htmlText = textArea["htmlText"];
 >               
 >                for (var i:int=0; i<listOfWordPositions.length; i++) 
 > {       
 >                   var metaWord:WordPositions = listOfWordPositions[i];
 >                   tr.beginIndex = metaWord.startIndex;
 >                   tr.endIndex = metaWord.endIndex;
 >                   tr.htmlText = formattedText(tr.text, 
 > metaWord.color);              
 >                      //tr["color"] = metaWord.color;
 >                      //tr["fontWeight"] = "bold";
 >                      //tr["fontSize"] = 12;
 >                }                         
 >           }
 >          
 >         private function formattedText(text:String, color:uint):String {
 >             return "<FONT style='BACKGROUND-COLOR: " + color + "'>" + 
 > text + "</FONT>";   
 >         }
 >
 >
 > TextRange seems to be very limited on how much you can format your 
 > html text so I'm not surprised it doesnt really fully support HTML. 
 > Any workaround to get a similar behavior?
 > Changing the text color, size and weight works though (see commented 
 > out lines).
 >
 > -Stephen
 >
 > 
 >
 > __________ NOD32 3118 (20080521) Information __________
 >
 > This message was checked by NOD32 antivirus system.
 > http://www.eset.com
 hi,
 
 have you tried the highlighter from flexlib? take a look at:
 
 
http://flexlib.googlecode.com/svn/trunk/examples/Highlighter/Highlighter_Sample.swf
 
 kind regards,
 
 Frederico Garcia
 
     
                                       

       

Reply via email to