Recently I was trying to figure out how to make the padding in the cells of a <mx:comboBox> smaller than the default. This proved to be much harder than I thought. But I eventually found a solution.
Here is what the default looks like:

Here is the code I came up with:
<mx:Script xmlns:mx="http://www.adobe.com/2006/mxml">
<![CDATA[
import mx.controls.Alert;
import mx.core.Application;
import mx.events.DropdownEvent;
public var app:* = Application( Application.application );
private function comboBox_open(evt:DropdownEvent):void {
evt.currentTarget.dropdown.variableRowHeight = true;
}
]]>
</mx:Script>
<mx:ComboBox id=”myComboBox” dataProvider=”{mx.core.Application.application.bbapp.cityXML}” labelField=”NAME”
close=”app.closeHandler(event)” cornerRadius=”0? dropdownStyleName=”gameSelectBox” visible=”false” fontSize=”12? open=”comboBox_open(event);”>
<mx:itemRenderer>
<mx:Component>
<mx:Label text=”{data.NAME}” paddingTop=”-5? paddingBottom=”-5?/>
</mx:Component>
</mx:itemRenderer>
</mx:ComboBox>
</mx:HBox>

If you like this post and would like to receive updates from this blog, please subscribe our feed.
March 4th, 2009 at 3:29 pm
Just an FYI, you can more easily perform your desired change in padding simply by including those elements in your style. In your example, you have specified the dropdownStyleName to be ‘gameSelectBox’. Within the ‘gameSelectBox’ style definition, you can simply put your paddingTop and paddingBottom elements. That way you will not need to do a custom item renderer.