2011-12-01 66 views
0

我在將backgroundColor應用於Flash中的TextInput組件時遇到了問題。我有一個名爲LastLayer的MoveClip;在這一層我通過使用組件設計了TextInput。現在我想爲TexInput添加背景顏色。任何人指導我。我如何添加背景顏色?提前致謝!要爲Flash中的textInput添加顏色?

txtUser是我的TextInput組件的實例名稱。我想這個代碼,但它不工作:

txtUser.setStyle("backgroundColor", "#000000")); 

回答

1

試試這個:

var tf:TextFormat = new TextFormat(); 
tf.size = 25; 
tf.color = 0xFF0000; 
var ti:TextInput = new TextInput(); 
ti.textField.background=true; 
ti.textField.backgroundColor = 0xffcc00; 
ti.x = 100; 
ti.y = 100; 
ti.width = 200; 
ti.height = 30; 
ti.text = "your text here"; 
ti.setStyle("textFormat", tf); 
addChild(ti); 
+0

好吧,我改變了文本在很多地方,如果我不喜歡這樣,我不能顯示的文字。因爲我加入孩子只有一次。 – Mercy

+0

我設計TextInput通過使用組件,我的文本輸入ID是txtUser。我試過這個code.txtUser.setStyle(「backgroundColor」,「#000000」)); – Mercy

+0

'txtUser.textField.background = true; txtUser.textField.backgroundColor = 0x000000;' – AsTheWormTurns