Chapter 17 Example 5

by actionscriptbible
♥0 | Line 31 | Modified 2009-06-29 06:16:06 | MIT License
play

ActionScript3 source code

/**
 * Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/9zON
 */

package {
  import flash.display.Sprite;
  import flash.text.StyleSheet;
  import flash.text.TextField;
  
  public class ch17ex5 extends Sprite {
    protected const TEXT:String =
"<h1>Quiet Girl</h1>" +
'<h2>by <a href="http://en.wikipedia.org/wiki/Langston_Hughes">' + 
"Langston Hughes</a></h2>\n" + 
"<p>I would liken you<br>To a night without stars<br>" + 
"Were it not for your eyes.<br>I would liken you<br>" + 
"To a sleep without dreams<br>Were it not for your songs.";

    protected const CSSRULES:String =
"h1 {font-family: sans-serif; font-size: 14; color: #202020}" + 
"h2 {font-family: sans-serif; font-size: 12; color: #303030}" + 
"a {font-style: italic; text-decoration: underline}" + 
"a:hover {font-style: italic; text-decoration: underline; color: #303080}" + 
"p {font-family: serif; text-align: center; font-size: 20; leading: 8}";

    public function ch17ex5() {
      var styleSheet:StyleSheet = new StyleSheet();
      styleSheet.parseCSS(CSSRULES);
      var tf:TextField = new TextField();
      tf.styleSheet = styleSheet;
      
      tf.width = stage.stageWidth;
      tf.height = stage.stageHeight;
      tf.multiline = true;
      addChild(tf);
      
      tf.htmlText = TEXT;
    }
  }
}