首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

flex界面 单选按钮,复选框旋钮实现 button.mxml

2012-10-24 
flex界面 单选按钮,复选框按钮实现 button.mxml?xml version1.0 encodingutf-8?s:Application xm

flex界面 单选按钮,复选框按钮实现 button.mxml
<?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/halo"
   minWidth="1024" minHeight="768"
   creationComplete="initApp()" xmlns:mx2="library://ns.adobe.com/flex/mx" width.default="1024" width.hospital="1162" height.hospital="804" backgroundColor.default="#38726D" height.default="768">
<fx:Style source="mylogin.css"/>
<fx:Script>
<![CDATA[
import mx.containers.ViewStack;
import mx.controls.Alert;
import mx.events.MenuEvent;


private function initApp():void
{
//显示校验码
lblCheckCode.text = GenerateCheckCode();

}

protected function btnLogin_clickHandler(event:MouseEvent):void
{
if(txtUsername.text == "" || txtPassword.text == "")//用户输入的用户名和密码为空
{
Alert.show("请输入完整数据!");
}
else
{
//合法用户
if(txtUsername.text == "admin" && txtPassword.text == "admin"
&&txtCheckCode.text.toLowerCase() == lblCheckCode.text.toLowerCase())
{
//Alert.show("登录成功!");
currentState = "hospital";
}
else//登录失败
{
//校验码错误
if(txtCheckCode.text.toLowerCase() != lblCheckCode.text.toLowerCase())
{
Alert.show("校验码错误!");
//重新生成校验码
lblCheckCode.text = GenerateCheckCode();
}
//用户名或密码错误
else
Alert.show("用户名或密码错误!");
}
}

}


protected function btnReset_clickHandler(event:MouseEvent):void
{
txtUsername.text = "";
txtPassword.text = "";
}

//生成随机码
private function GenerateCheckCode():String
{
//初始化
var ran:Number;
var number:Number;
var code:String;
var checkCode:String ="";
//生成四位随机数
for(var i:int=0; i<4; i++)
{
ran=Math.random();//Math.random生成数为类似为0.1234
number =Math.round(ran*10000);
if(number % 2 == 0)//如果是2的倍数生成一个数字
//"0"的ASCII码是48
code = String.fromCharCode(48+(number % 10));
else//生成一个字母
//"A"的ASCII码为65
code = String.fromCharCode(65+(number % 26));
checkCode += code;
}
return checkCode;
}

]]>


</fx:Script>
<s:states>
<s:State name="default"/>
<s:State name="index"/>
<s:State name="hospital"/>
<s:State name="button"/>
<s:State name="change"></s:State>
</s:states>
<fx:Declarations>
<s:RadioButtonGroup id="radiogroup1"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:layout.default>
<s:HorizontalLayout verticalAlign="middle" gap="0"/>
</s:layout.default>
<s:Panel x="335" y="217" width="451" height="366" title="用户登录" fontFamily="Georgia" includeIn="default" id="KG" fontSize="20" backgroundColor="#2FDA0D" contentBackgroundColor="#8C7C7C" chromeColor="#101830">
<s:Label x="85" y="42" text="用户名" fontSize="20" width="76" height="28"/>
<s:Label x="85" y="109" text="密码" width="76" height="39" fontSize="20"/>
<s:TextInput x="193" y="42" id="txtUsername" height="28" width="162"/>
<s:TextInput x="193" y="109" id="txtPassword" displayAsPassword="true" height="30" width="162"/>
<s:Button x="82" y="248" label="登录" id="btnLogin" click="btnLogin_clickHandler(event)" width="94" height="41" fontSize="20"/>
<s:Button x="255" y="248" label="重置" id="btnReset" click="btnReset_clickHandler(event)" width="100" height="41" fontSize="20"/>
<s:Label x="85" y="182" text="校验码" height="33" width="64" fontSize="20"/>
<s:TextInput x="193" y="182" width="83" id="txtCheckCode" height="24"/>
<s:Label x="284" y="182" id="lblCheckCode" width="71" height="24" fontSize="20"/>
</s:Panel>
<s:Label includeIn="index" x="225" y="52" text="欢迎来到主页" fontFamily="Georgia" fontSize="15" color="#EAC248"/>
<s:Panel includeIn="hospital" x="0" y="10" width="1161" height="815" title="患者基本信息" fontSize="20">
<s:Label x="46" y="34" width="79" height="21" text="患者姓名" fontSize="16" id="txtIllname"/>
<s:TextInput x="154" y="25" width="309" height="30" id="txtNameinput"/>
<s:Label x="42" y="76" text="患者身份证号" width="104" height="19" fontSize="16" id="myid"/>
<s:TextInput x="154" y="63" width="308" height="32"/>
<s:Label x="46" y="128" text="入院情况" width="79" height="22" fontSize="16" id="ruyuan"/>
<s:TextInput x="154" y="115" width="957" height="120"/>
<s:Label x="46" y="233" text="诊治经过" width="79" height="24" fontSize="16" id="zhenzhi"/>
<s:TextInput x="154" y="243" width="957" height="100" chromeColor="#EEF3EB"/>
<s:Label x="42" y="347" text="重要发现结论" width="104" height="27" id="foundinput" fontSize="16"/>
<s:TextInput x="154" y="351" width="957" height="89"/>
<s:Label x="42" y="468" text="接受的手术操作" width="115" height="26" id="caozuo" fontSize="16"/>
<s:TextInput x="155" y="448" width="956" height="98"/>
<s:Label x="42" y="566" text="结论" width="79" height="35" id="jielun" fontSize="16"/>
<s:Button   x="425" y="671" label="保存" width="112" height="34" id="btnClick" click="btnClick"/>
<s:Button x="800" y="671" label="退出" width="127" height="34" id="tuichu"/>
<s:TextArea x="152" y="554" width="959" height="107"/>

</s:Panel>
</s:Application>

热点排行