您当前的位置: 首页 > 

Jave.Lin

暂无认证

  • 2浏览

    0关注

    704博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

AS3 NumericUpDown ---- 数字调节器

Jave.Lin 发布时间:2012-04-13 15:31:56 ,浏览量:2

测试类:

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.width200)
			{
				dW=-5;
			}
			
			if(nud.height100)
			{
				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;
		}
	}
}

下载运行实例: NumericUpDownTest.swf 运行图片效果:

关注
打赏
1664331872
查看更多评论
立即登录/注册

微信扫码登录

0.0373s