flex软件盘

1.先下载Vendy.KeyBoard.swc放到libs文件夹下。

2.添加如下代码:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:VendyKeyBoard="VendyKeyBoard.*"
			   creationComplete="appInit(event)">
	<s:layout>
		<s:BasicLayout/>
	</s:layout>
	<fx:Script>
		<![CDATA[
			import VendyKeyBoard.KeyBoardEvent;
			
			import mx.events.FlexEvent;
			//键盘输入
			[Bindable]
			private var InputWord:String;
			//初始化
			protected function appInit(event:FlexEvent):void{
				mykeyboard.SetKeyBoard="数字";
				InputWord="";
			}
			protected function mykeyboard_inputHandler(e:KeyBoardEvent):void
			{
				switch(e.type){
					case "input":
						InputWord+=e.InputWord;
						break;
					case "boardChange":
						//InputType=mykeyboard.GetInputType
						break;
					case "del":
						InputWord=InputWord.slice(0,InputWord.length-1);
						break;
				}
			}


			protected function mykeyboard_delHandler(e:KeyBoardEvent):void
			{
				switch(e.type){
					case "input":
						InputWord+=e.InputWord;
						break;
					case "boardChange":
						//InputType=mykeyboard.GetInputType
						break;
					case "del":
						InputWord=InputWord.slice(0,InputWord.length-1);
						break;
				}
			}


			protected function mykeyboard_boardChangeHandler(e:KeyBoardEvent):void
			{
				switch(e.type){
					case "input":
						InputWord+=e.InputWord;
						break;
					case "boardChange":
						//InputType=mykeyboard.GetInputType
						break;
					case "del":
						InputWord=InputWord.slice(0,InputWord.length-1);
						break;
				}
			}
			
			protected function key_clickHandler(event:MouseEvent):void {
				if(this.mykeyboard.visible == false) {
					this.mykeyboard.x = this.jianpan.x-25;
					this.mykeyboard.y = this.jianpan.y+25; 
					kbFadeEft.play();
					//	this.mykeyboard.visible = true;
					this.upwd.enabled = false;
				} else {
					kbFadeEftOut.play();
					//	this.mykeyboard.visible = false;
					this.upwd.enabled = true;
				}
			}

		]]>
	</fx:Script>
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
		<s:Fade id="kbFadeEft" target="{mykeyboard}" alphaFrom="0" alphaTo="1" 
				duration="1000" effectEnd="mykeyboard.visible = true"/>
		<s:Fade id="kbFadeEftOut" target="{mykeyboard}" alphaFrom="1" alphaTo="0" 
				duration="500" effectEnd="mykeyboard.visible = false"/>
	</fx:Declarations>
	<s:Label text="密码" x="40" y="60"/>
	<s:TextInput id="upwd" x="120" y="60" width="106" 
				 displayAsPassword="true" text="{InputWord}"/>
	<mx:Image id="jianpan" source="screenshot.png" x="228" y="60" 
			  width="22" height="22" click="key_clickHandler(event)"/>
	<VendyKeyBoard:KeyBoard id="mykeyboard" x="115" y="165" 
							scaleX="0.25" scaleY="0.16"	visible="false"
							input="mykeyboard_inputHandler(event)"
							del="mykeyboard_delHandler(event)"
							boardChange="mykeyboard_boardChangeHandler(event)"/>
</s:Application>


3.运行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值