Issue with skinning ComboBox: Highlight border
Today I had an issue with skinning a ComboBox. Within a Flash form a ComboBox should be highlighted with a red border for displaying an error, but I couldn’t use ComboBoxes "borderStyle" property to solve this issue.
It took me several minutes to figure out how to do the simplest of things. I’ve dug out mx.controls.ComboBox and its super classes detecting a TextInput named “text_mc” located in mx.controls.ComboBase which draws the border.
Solution
First you have to point to “text_mc”. ComboBox supports this reference with comboBoxInstance.textField. Change its default "borderStyle" named "dropDown" to "solid" for skinning the border. Then just customise the style called "borderColor":
-
comboBoxInstance.textField.setStyle("borderStyle" , "solid");
-
comboBoxInstance.textField.setStyle("borderColor" , 0xCC0000);
Result

thank you
Awesome! This blog post helped! I searched and searched, and found you’re kind share. Thanks!
So apparently comboBoxInstance.setStyle(“borderStyle” , “solid”); styles the border of the dropdown part of the comboBox,
while comboBoxInstance.textField.setStyle(“borderStyle” , “solid”); styles the closed comboBox border
I was just thinking that why
_global.styles.ComboBox.setStyle
doesn’t work? Why it is necessary to mention the instance name of the combo box as you did,
comboBoxInstance.textField.setStyle
…Is it due to the fact taht the way I am trying to associate a style…won’t work…I should apply it rather in the inherited style fashion.
Usman,
the border is created by a TextInput instance located in ComboBox not by the ComboBox itself. For styling this border you have to point this instance via
“comboBoxInstance.textField.setStyle(style , value);”
because the ComboBox does’nt support this.
Cheers
-sectore
Thanks, you saved my hair. Adobe’s online doc skipped this.
Posting was very helpful. I played with tons of different styles until your post showed that you MUST set the borderStyle and then you can set the color etc,. Thanks!
I modified the combobox skin in Flash to suit my needs, but that annoying border remained. I spent the last night trying to figure out how to remove it.. and voila.. Thank you:))
In actionscript 3 (flex), there is no textField property of combobox. How do you do that?
Xiaofei,
sorry, the solution described above is for AS2 and Flash only.
-Jens
Thank you.
I am using AS3 and this does not work and produce error.
Error: Access of possibly undefined property
text_mc through a reference with static type mx.controls:ComboBox.
For those who are trying to find a workaround for this in Flex 3 – I found no other way to do it than simply to place a combo box into a canvas and toggle the red border of the canvas itself on error.
Hi,
Thanks a lot. I have spent a whole day for this, I need this for skinning a layout
Thanks again
Thanks a lot. I was searching whole night in the flash help and skining a component, but couldnt find anything which can work to set the border color. Just 2 lines of code fix the issue and now i can change the border color and also can remove it. Thanks again.