Using the StyleSheet with a TextField : StyleSheet « TextField « Flash / Flex / ActionScript






Using the StyleSheet with a TextField

 

package{
  import flash.display.Sprite;
  import flash.text.*;
  public class Main extends Sprite{
    public function Main(){

       var txt:TextField = new TextField();
       txt.multiline = true;
       txt.wordWrap = true;
       var cssString:String = ".redStyle{color:#FF0000; font-family:Arial;}.blueStyle{color:#0000FF; font-family:Courier;}";
       var styles:StyleSheet = new StyleSheet();
       styles.parseCSS(cssString);
       txt.styleSheet = styles;
       txt.htmlText = '<span class=" redStyle">This will show up red</span> And this will not. <span class=" blueStyle">This will show up blue</span>';
       addChild(txt);
    }
  }
}

        








Related examples in the same category