ComboBox文本格式通过AS3

4 air flash combobox actionscript-3

我正在开发一个AIR应用程序,我需要更改dropDown列表中显示的文本的字体大小以及comboBox上的主文本.我的ComboBox体积很大,但显示的文字非常小.我尝试通过将TextFormat传递给它来使用setStyle方法,如:

cmbEmployee.setStyle("textFormat",txtform);

但它不起作用.虽然相同的方法适用于TextField.

有人可以帮忙吗?

小智 7

好吧,ComboBox是一个包含TextField和DropDown列表的容器.因此,您无法直接在ComboBox本身上应用setStyle,而是需要将其应用于ComboBox内的特定元素.

// Text Formats that needs to be applied on your comboBox
var txtformat:TextFormat = new TextFormat(); 
    txtformat.size = 30;   // Lets just increase the size of fonts   

// Increase the main TextField's font size of your ComboBox
yourComboBox.textField.setStyle("textFormat", txtformat);

// Increase the font size to the dropdown component
yourComboBox.dropdown.setRendererStyle("textFormat", txtformat);
Run Code Online (Sandbox Code Playgroud)

试试吧 !