<?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" preloaderChromeColor="#C6EDC7" backgroundColor="#D29999" >
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<mx:Text x="247" y="48" id="title" text="密码输入框"/>
<s:TextInput x="320" y="47" id="passwd" displayAsPassword="true" borderVisible="true"/>
<s:Button x="373" y="297" label="cancel" id="cancel" click="reset()"/>
<s:Button x="242" y="297" label="ok" id="ok" click="nz()"/>
<s:Button x="226" y="126" label="1" id="btn1" click="addnum('1')"/>
<s:Button x="314" y="128" label="2" id="btn2" click="addnum('2')"/>
<s:Button x="399" y="126" label="3" id="btn3" click="addnum('3')"/>
<s:Button x="226" y="176" label="4" id="btn4" click="addnum('4')"/>
<s:Button x="314" y="176" label="5" id="btn5" click="addnum('5')"/>
<s:Button x="399" y="176" label="6" id="btn6" click="addnum('6')"/>
<s:Button x="226" y="228" label="7" id="btn7" click="addnum('7')"/>
<s:Button x="314" y="228" label="8" id="btn8" click="addnum('8')"/>
<s:Button x="397" y="228" label="9" id="btn9" click="addnum('9')"/>
<s:Button x="226" y="77" label="0" width="158" click="addnum('0')"/>
<s:Button x="395" y="77" label="删除" click="removenum()"/>
<s:Label x="286" y="360" width="114" height="64" fontSize="31" fontFamily="细明体" chromeColor="#EBDCDF" color="#F11241" id="labelok"/>
<fx:Script source="changebtn.as"></fx:Script>
</s:Application>
changebtn.as
// ActionScript file
public function addnum(num:String){
passwd.text+=num;
}
public function reset(){
passwd.text="";
}
public function nz(){
labelok.text=passwd.text;
}
public function removenum(){
var nums:String=passwd.text;
if (nums.length>0) passwd.text=nums.substr(0,nums.length-1);
}