Formatting XML content with a style sheet : StyleSheet : XML Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » XML » StyleSheet »

 

Formatting XML content with a style sheet


 

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";
        specialnoteDeclarationBlock.display    = "block";
        
        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>"
          "<specialnote>Set styleSheet before htmlText!</specialnote>"
          "<p>Otherwise, the stylesheet will not be applied.</p>";
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo XML
» StyleSheet