ActionScript 2.0 Components Language Reference |
|
|
|
| NumericStepper component > Using the NumericStepper component > Creating an application with the NumericStepper component | |||
The following procedure explains how to add a NumericStepper component to an application while authoring. The example places a NumericStepper component and a Label component on the Stage and creates a listener for a change event on the NumericStepper instance. When the value in the numeric stepper changes, the example displays the new value in the Label instance.
To create an application with the NumericStepper component:
/**
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.
|
|
|
|