搜尋部落格文章

2013年8月6日 星期二

TextField.styleSheet 套用CSS樣式表

import flash.text.StyleSheet;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
var myHTMLText:String = "

HTML Text (sample header)

Here is some sample html text "+"filling a text box this link to adrianparr.com and example headers"+"

Header h1

Header h2

Hello worldThis text will be red

Boo

";
var defaultStyleObj:Object = new Object();
defaultStyleObj.fontFamily = "Verdana";

var myStyleSheet:StyleSheet = new StyleSheet();
myStyleSheet.setStyle("body", {fontSize:'15',color:'#000066'});
myStyleSheet.setStyle("h1", {fontSize:'32',color:'#000000'});
myStyleSheet.setStyle("h2", {fontSize:'19',color:'#000000'});
myStyleSheet.setStyle("a:link", {color:'#0000CC',textDecoration:'none'});
myStyleSheet.setStyle("a:hover", {color:'#0000FF',textDecoration:'underline'});
myStyleSheet.setStyle("b", {fontWeight:'bold'});
myStyleSheet.setStyle("em", {fontWeight:'bold'});
myStyleSheet.setStyle(".defaultStyle", defaultStyleObj);
myStyleSheet.setStyle("redText", {color:'#FF0000'});

var myTextField:TextField = new TextField();
myTextField.width = 500;
myTextField.multiline = true;
myTextField.styleSheet = myStyleSheet;
myTextField.htmlText = myHTMLText;
myTextField.autoSize = TextFieldAutoSize.LEFT;
myTextField.wordWrap = true;
myTextField.border = true;
addChild(myTextField);

沒有留言:

張貼留言