我有以下代码,我的comboBox下拉样式,但我似乎无法获得背景颜色。我使用//注释来显示它不喜欢的行:
var myTextFormat:TextFormat = new TextFormat();
myTextFormat.font = "Arial";
myTextFormat.color = 0xFFFFFF;
myTextFormat.size = 10;
myTextFormat.background = true; // Doesn't like this line
myTextFormat.backgroundColor = 0xFFFFFF; // Doesn't like this line
var m = 0;
function comboBoxChange(e:Event):void {
var scriptVars:URLVariables = new URLVariables();
trace("YOU CHANGED ME!!!");
//scriptVars["InstructorName" + [m]] = myXML.Instructors.InstructorName[m];
trace(e.target.selectedItem.label);
//Change the comboBox color if Instructor selected
// Go back to plain if no Instructor
if (e.target.selectedIndex == 0){
trace("EMPTY");
e.target.transform.colorTransform = new ColorTransform;
}
else
{
// Shade of black indicates slot allocated to Instructor
my_color.color = 0x002222;
//e.target.transform.colorTransform = my_color;
e.target.parent.alpha = 1;
e.target.textField.setStyle ("textFormat",myTextFormat);
}
}
答案 0 :(得分:1)
您所寻找的是contentBackgroundColor
风格的ComboBox
?
s|ComboBox {
contentBackgroundColor: red;
}
或
combo.setStyle('contentBackgroundColor', 'red');
答案 1 :(得分:1)
这似乎有效: e.target.textField.textField.background = true; e.target.textField.textField.backgroundColor = 0x000000;