测试类:
package test
{
import controlsEvents.NumericeUpDownEvent;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
public class NumericUpDownTest extends Sprite
{
private var author:Label;
private var nud:NumericUpDown;
private var lb:Label;
private var bt:Button;
public function NumericUpDownTest()
{
super();
stage.color=0xccccbb;
stage.frameRate=60;
stage.align=StageAlign.TOP_LEFT;
stage.scaleMode=StageScaleMode.NO_SCALE;
author=new Label();
addChild(author);
author.textColor=0x00ff00;
author.fontSize=24;
author.x=100;
author.y=50;
author.text="作者:Jave.Lin";
nud=new NumericUpDown();
addChild(nud);
nud.x=100;
nud.y=100;
nud.maxValue=10000;
nud.minValue=100;
nud.addEventListener(NumericeUpDownEvent.VALUE_CHANGED,onValueChangedHandler);
lb=new Label();
addChild(lb);
lb.x=50;
lb.y=120;
lb.text="NumericUpDownTest minValue:"+nud.minValue+" maxValue:"+nud.maxValue+" value:"+nud.curValue;
bt=new Button();
addChild(bt);
bt.text="setup or unset enterframe"
bt.x=100;
bt.y=200;
bt.addEventListener(MouseEvent.CLICK,onClick);
}
private var dW:Number=5;
private var dH:Number=5;
private function onEnterFrame(e:Event):void
{
if(nud.width<50)
{
dW=5;
}
else if(nud.width>200)
{
dW=-5;
}
if(nud.height<40)
{
dH=5;
}
else if(nud.height>100)
{
dH=-5;
}
nud.setWidthHeight(nud.width+dW,nud.height+dH);
}
private function onClick(e:MouseEvent):void
{
if(nud.hasEventListener(Event.ENTER_FRAME))
{
nud.removeEventListener(Event.ENTER_FRAME,onEnterFrame);
}
else
{
nud.addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
}
private function onValueChangedHandler(e:NumericeUpDownEvent):void
{
lb.text="NumericUpDownTest minValue:"+nud.minValue+" maxValue:"+nud.maxValue+" value:"+e.value;
}
}
}
运行图片效果: