Hello Friends,

I need a small help. I just strucked up with NumericStepper issue.

I have a NumericStepper and i am setting the Minimum value to 0 & Maximum value to 10. Now my requirement is, suppose if the user entered/typed the value which is greater than Maximum value (ie 10) inside NumericStepper inputbox I want to display that particular value in "RED" color. how to do this.

Your help would be appreciated, i need a solution asap.
I am attaching the code what i am doing.......


package
{
import fl.controls.Label;
import fl.controls.NumericStepper;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.*;

public class NumericStepperExample extends Sprite
{
private var ns1:NumericStepper;
private var ns2:NumericStepper;
private var lbl1:Label;
private var lbl2:Label;
private var rowHeight1:Number = 100;
private var rowHeight2:Number = 50;

public function NumericStepperExample() {
setupSteppers();
setupLabels();
}

private function setupLabels():void {
lbl1 = new Label();
lbl1.text = "Min Value -- 0 and Max Value -- 10";
lbl1.autoSize = TextFieldAutoSize.LEFT;
lbl1.move(200, rowHeight1);
addChild(lbl1);
}

private function setupSteppers():void {
ns1 = new NumericStepper();
ns1.stepSize = 1;
ns1.minimum = 0;
ns1.maximum = 10;
ns1.width = 60;
ns1.move(100, rowHeight1);
ns1.addEventListener(Event.CHANGE, changeOccurred);
addChild(ns1);

}

private function changeOccurred(e:Event):void {
var nsTarget:NumericStepper = e.target as NumericStepper;

var redColor:TextFormat = new TextFormat();
redColor.color = 0xff0000;

var blackColor:TextFormat = new TextFormat();
blackColor.color = 0x000000;

if (nsTarget.value > nsTarget.maximum) {
nsTarget.setStyle("textFormat", redColor);
} else {
nsTarget.setStyle("textFormat", blackColor)
}
}
}
}

Rajesh