2009-02-16 66 views
0

任何想法,爲什麼文本字段()有時保持加粗(即使格式是通過setTextFormat()復位)這樣?:的TextField(),有時保持加粗即使HTML風格是通過setTextFormat()重置

myFormat.bold=false; 
defaultTextFormat =myFormat; 
defaultTextFormat.bold = false; 
setTextFormat(myFormat); 

htmlText("This text is bold even when it should not be.") 

PS:TextField是可編輯的,並且在用戶編輯時會出現問題。

更新:我想擺脫所有的格式,以避免不需要的大膽。 TextField有一個錯誤,當粗體字由用戶背棄時,TextField中的所有內容都會以粗體顯示。

+0

請問您是否可以詳細說明「用戶編輯時出現問題」的含義?這是否意味着刪除粗體,但是當用戶開始編輯時會重新應用?或者,即使更改了defaultTextFormat,用戶輸入的新文本仍然是粗體的? – 2009-02-16 13:55:24

回答

0

我相信,通過TextField控件,您需要設置TextFeild.styleSheet來更改HTML樣式。嘗試類似這樣的:

var myText:TextField = new TextField(); 
var style:StyleSheet = new StyleSheet(); 
var fonts:String = "Helvetica Neue, Arial, _sans"; 
style = new StyleSheet(); 
style.setStyle(".body", {fontFamily:fonts, fontSize:"12", fontWeight:"normal", color:"#222222", textDecoration:"none"}); 
myText.styleSheet = style; 
myText.htmlText = "this is bold even when should not";