Formatting Text with HTML : htmlText « TextField « Flash / Flex / ActionScript






Formatting Text with HTML

 

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

        var t:TextField = new TextField(  );
        t.autoSize = TextFieldAutoSize.LEFT;
        
        var message:String = "<FONT FACE='Arial' SIZE='20'>"
                           + "<B>ActionScript is fun!</B></FONT>";
        
        
        t.htmlText = message;
        //HTML text is assigned directly to the htmlText variable
        t.htmlText = "<FONT FACE='Arial' SIZE='20'>"
                     + "<B>ActionScript is fun!</B></FONT>";
        
        addChild(t);
    }
  }
}

        








Related examples in the same category

1.Displaying HTML-Formatted Text
2.Use html text in TextField
3.Escape HTML tags bracket
4.Add HTML new line tag in TextField
5.Make the text font italic
6.Use HTML hyperlink in TextField
7.Condensing Whitespace
8.Formatting Text by using HTML tags
9.Adding a Hyperlink to Text
10.Add a Hyperlink to Text with target
11.Set link color
12.Specify a target window into which the link opens
13.Use HTML to make the text bold
14.Quoting attribute values
15.Interactions between the text and htmlText variables
16.Set both text and htmlText
17.Adding Mail Links
18.Calling JavaScript Functions
19.Embedding Content in Text
20.Use img tag in TextField
21.Embed a SWF file