Tag Archives: alignment

Flex Checkbox Label Vertical Alignment

If you notice the label of a checkbox is not centered vertically by default and there is no property to adjust the vertical alignment of the label. The property provided in the API is changing the location of a label. There wasn’t any solution available on the internet to this issue. Hence I came up with a solution that inherit from CheckBox class and in the updateDisplayList method set the ‘y’ location of its label. You can even apply some css style to the label.

public class InputCheckBox extends CheckBox
{
       override protected function updateDisplayList(unscaledWidth:Number,  unscaledHeight:Number):void
       {
              super.updateDisplayList(unscaledWidth, unscaledHeight);
              textField.styleName = 'InputCheckBoxLabel';
              textField.y = 3;
       }
}
Advertisements