Formatting applied to a specific class of paragraph : StyleSheet « Development « Flash / Flex / ActionScript






Formatting applied to a specific class of paragraph

 

package{
  import flash.display.Sprite;
  import flash.text.*;
  public class Main extends Sprite{
    public function Main(){
        var specialnoteDeclarationBlock:Object = new Object(  );
        specialnoteDeclarationBlock.fontFamily = "Arial"
        specialnoteDeclarationBlock.fontSize   = "20";
        specialnoteDeclarationBlock.fontWeight = "bold";
        
        var styleSheet:StyleSheet = new StyleSheet(  );
        styleSheet.setStyle(".specialnote", specialnoteDeclarationBlock);
        
        var t:TextField = new TextField(  );
        t.width     = 300;
        t.wordWrap  = true;
        t.multiline = true;
        t.styleSheet = styleSheet;
        t.htmlText = "<p>Always remember...</p>"
          + "<p class='specialnote'>Set styleSheet before htmlText!</p>"
          + "<p>Otherwise, the stylesheet will not be applied.</p>";
    }
  }
}

        








Related examples in the same category

1.Text formatted with an external style sheet
2.Load a CSS document and use that data to populate a StyleSheet object
3.Use CSS to in TextField
4.Formatting text with a programmatically created style sheet
5.Set the font with CSS