0 Replies Latest reply on May 14, 2007 12:18 PM by szhang8888

    How to highlight a line in Textarea component


      I'm trying to use the Textarea component to show source codes, and I want to be able to highlight a line in the textarea. I want the highlight behavior similar to the way a tree node is highlighted or the grid/list component is highlighted, both with just one click. I'm not able to find any information on how to do it in the Textarea component. Currently i'm only able to change the text's foreground color, which does not really look that good. Thanks in advance for your help.

      public function highLightLine(lineNumber:int, highLight:Boolean):void
      if (lineNumber == 0) {

      if (text == null || text.length == 0) {

      var beginIndex:int = 0;
      var endIndex:int = 0;
      for (var i:int; i < lineNumber-1; i++) {
      beginIndex = text.indexOf("\r", beginIndex) + 1;
      endIndex = text.indexOf("\r", beginIndex);

      var textFormat:TextFormat = new TextFormat();
      if (highLight == true) {
      textFormat["color"] = 0xFF0000;
      } else {
      textFormat["color"] = 0x0000a0;
      textField.setTextFormat(textFormat, beginIndex, endIndex);