现在的位置: 首页 > 综合 > 正文

登陆实例

2018年02月12日 ⁄ 综合 ⁄ 共 2152字 ⁄ 字号 评论关闭

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>
<![CDATA[
import mx.controls.Alert;
public function check():void
{
var btn:Boolean = true;
if(username.text == "")
{
Alert.show("用户名不能为空!");
btn = false;
username.setFocus();
}
if(password.text.length<3||password.text.length>16)
{
Alert.show("密码长度不合法");
btn = false;
password.setFocus();
}
if(DateField1.text == "")
{
Alert.show("日期不能为空");
btn = false;
DateField1.setFocus();
}
var ssex:String = "";
if(sexM.selected == true)
{
ssex += sexM.label;
}
if(sexW.selected == true)
{
ssex += sexW.label;
}
var sel:String = "";
if(ch1.selected == true)
{
sel += ch1.label;;
}
if(ch2.selected == true)
{
sel += ch2.label;;
}
if(ch3.selected == true)
{
sel += ch3.label;;
}
if(ch4.selected == true)
{
sel += ch4.label;;
}
if(btn == true)
{
Alert.show("注册成功\n用户名:" + username.text + "\n密码为:" + password.text + "\n日期为:" + DateField1.text + "\n性别:" + ssex +"\n爱好:" + sel)
}
}

public function initValue():void
{
DateField1.monthNames=["一月", "二月", "三月", "四月", "五月",
    "六月", "七月", "八月", "九月", "十月", "十一月",
    "十二月"];

DateField1.dayNames=["日","一","二","三","四","五","六"];

var d:Date = new Date();
d.setFullYear(1985,07,19);
DateField1.selectedDate = d;

DateField1.formatString = "YYYY年MM月DD日";
}
]]>
</mx:Script>
<mx:Panel x="76" y="10" width="563" height="390" layout="absolute">
<mx:TextInput x="153" y="19" fontSize="12" id="username"/>
<mx:TextInput x="153" y="62" fontSize="12" displayAsPassword="true" id="password"/>
<mx:Label x="73" y="21" text="用户名" fontSize="12"/>
<mx:Label x="73" y="64" text="密  码" fontSize="12"/>
<mx:Label x="73" y="103" text="出生日期" fontSize="12"/>
<mx:DateField x="153" y="101" fontSize="12" id="DateField1" focusIn="initValue();"/>
<mx:Label x="75" y="148" text="性  别" fontSize="12"/>
<mx:RadioButton x="153" y="148" label="男" fontSize="12" id="sexM" groupName="sex"/>
<mx:RadioButton x="225" y="148" label="女" groupName="sex" id="sexW" fontSize="12"/>
<mx:Label x="75" y="191" text="爱  好" fontSize="12"/>
<mx:CheckBox x="153" y="191" label="美女" id="ch1" fontSize="12"/>
<mx:CheckBox x="213" y="191" label="野兽" fontSize="12" id="ch2"/>
<mx:CheckBox x="283" y="191" label="魔法" id="ch3" fontSize="12"/>
<mx:CheckBox x="349" y="191" label="足球" id="ch4" fontSize="12"/>
<mx:Button x="75" y="255" label="提交" fontSize="12" click="check();"/>
</mx:Panel>

</mx:Application>

抱歉!评论已关闭.