Search code examples
actionscript-3flashaircombobox

ComboBox Text Formatting through AS3


I am developing an AIR application and I need to change the font size of the text that is displayed in the dropDown List as well as the main text on the comboBox. My ComboBox is quite big in size but the text displayed in it is very small. I tried using the setStyle method by passing a TextFormat into it like :

cmbEmployee.setStyle("textFormat", txtform);

but it didn't work. Although the same method works well with a TextField.

Can somebody help ?


Solution

  • A ComboBox is a container that contains a textField and a dropdown component. You need to apply the "styles" to the specific components inside of the 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);