User Guide

132 CheckBox component
4. Now, add the following ActionScript to create an event listener and an event handler
function:
// Create handler for checkBox event.
function checkboxHandler(evt_obj:Object) {
minimumAge_ti.enabled = evt_obj.target.selected;
maximumAge_ti.enabled = evt_obj.target.selected;
}
// Add Listener.
testAge_ch.addEventListener("click", checkboxHandler);
This code creates a click event handler that enables and disables the minimumAge and
maximumAge text field components. For more information, see CheckBox.click,
“EventDispatcher.addEventListener()” on page 501 and TextInput component
on page 1209.
Customizing the CheckBox component
You can transform a CheckBox component horizontally and vertically while authoring and at
runtime. While authoring, select the component on the Stage and use the Free Transform tool
or any of the Modify > Transform commands. At runtime, use the
setSize() method
(
UIObject.setSize()) or any applicable properties and methods of the CheckBox class.
Resizing the check box does not change the size of the label or the check box icon; it only
changes the size of the bounding box.
The bounding box of a CheckBox instance is invisible and also designates the hit area for the
instance. If you increase the size of the instance, you also increase the size of the hit area. If the
bounding box is too small to fit the label, the label is clipped to fit.
Using styles with the CheckBox component
You can set style properties to change the appearance of a CheckBox instance. If the name of a
style property ends in “Color”, it is a color style property and behaves differently than
noncolor style properties. For more information, see “Using styles to customize component
color and text” in Using Components.