Flash / Flex / ActionScript/TextField/StyleSheet

Материал из Web эксперт
Перейти к: навигация, поиск

Using the StyleSheet with a TextField

   <source lang="java">

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 = "This will show up red And this will not. This will show up blue";
      addChild(txt);
   }
 }

}

       </source>