html與css在flash中的應用:
不小心看到同事den在弄個小東西:在flash里使用html和css,代碼是這樣:
var mystyle:textfield.stylesheet = new textfield.stylesheet();
mystyle.load("sample.css");
content_txt.stylesheet = mystyle;
content_txt.multiline= true;
content_txt.wordwrap = true;
content_txt.html = true;
var story:xml = new xml();
story.ignorewhite = true;
story.load("sample.html");
story.onload = function () {
content_txt.htmltext = story;
}
這個是加載外部css跟html(其實是加載xml當html用-_-b )的。后來den寫了兩種把樣式寫在as里的方式:
var css_str:string = ".aoao{color:#010101;font-weight:bold;} .aoao:hover{color:#ff0000}";
mystyle.parsecss(css_str)mystyle.setstyle(".aoao", {color:'#010101', fontweight:'bold'});
mystyle.setstyle(".aoao:hover", {color:"#ff0000"});
其實html也可以寫在as里面,直接拼string就行。對于css在寫在as里還是加載外部css就要看情況了,用web上還要考慮請求數,文件大小,緩存,更重要的是維護成本。不過在web應用我也沒想到有什么比較適合的應用,在瀏覽器里使用html加載flash之后再用flash加載html和css意義并不大,而且支持不是一般的弱,看一下支持的html標簽跟css屬性,=。= 本來想用來解決中文下劃線的問題,結果還是不行,據說別人是用flash畫下劃線滴。
瀏覽器的應用玩玩就算了。還是留在桌面應用吧。
新聞熱點
疑難解答