User Guide
972 NumericStepper component
5. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code:
/**
Requires:
- NumericStepper component on Stage (instance name: my_nstep)
- Label component on Stage (instance name: my_label)
*/
var my_nstep:mx.controls.NumericStepper;
var my_label:mx.controls.Label;
my_label.text = "value = " + my_nstep.value;
//Create listener object.
var nstepListener:Object = new Object();
nstepListener.change = function(evt_obj:Object) {
my_label.text = "value = " + evt_obj.target.value;
};
//Add listener.
my_nstep.addEventListener("change", nstepListener);
The last line of code adds a change event handler to the my_nstep instance. The handler
(
nstepListener) assigns the current value in the numeric stepper to the text property of
the Label instance.
Customizing the NumericStepper
component
You can transform a NumericStepper 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 (see
UIObject.setSize()) or any applicable properties and methods of the
NumericStepper class. (See “NumericStepper class” on page 975.)
Resizing the NumericStepper component does not change the size of the down and up arrow
buttons. If the stepper is resized to be greater than the default height, the arrow buttons are
pinned to the top and bottom of the component. The arrow buttons always appear to the
right of the text box.