Flex 带验证码的登陆页面
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp()">
<mx:states>
<mx:State name="index">
<mx:RemoveChild target="{loginPanel}"/>
<mx:AddChild position="lastChild">
<mx:Label text="欢迎来到主页" fontFamily="Georgia" fontSize="20"/>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function initApp():void{
lblCheckCode.text=GenerateCheckCode();
}
private function loginHandle():void
{
if(txtUsername.text==""||txtPassword.text==""){
Alert.show("用户名或者密码输入不完整!");
}
if(txtUsername.text=="admin" && txtPassword.text=="admin" && txtCheckCode.text.toLocaleLowerCase()==lblCheckCode.text.toLocaleLowerCase()){
currentState="index";
}else{
if(txtCheckCode.text.toLocaleLowerCase()!=lblCheckCode.text.toLocaleLowerCase()){
Alert.show("验证码不正确!");
lblCheckCode.text=GenerateCheckCode();
txtCheckCode.text="";
}else{
Alert.show("用户名或密码输入不正确!");
}
}
}
private function resetHandle():void{
txtUsername.text="";
txtPassword.text="";
&nb
相关文档:
Flex端代码:
<?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"
>
<fx:Script>
<!--[C ......
本帖最后由 flashyiyi 于 2009-2-22 23:18 编辑
最终我决定还是用“隐藏”这个不是很合适的词。mx_internal是一个自定义命名空间,至于“命名空间”到底是什么就不在这里说了。总之,当我们在代码头部写上:
use namespace mx_internal
(如果是.AS文件,需要手动import mx.core.mx_internal,注 ......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical">
<mx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridListData;
imp ......
这里分两种情况,一种是数据源在MXML文件中,如:
<mx:XML id="treeXML"
format="e4x">
<root>
<node label="通知通告管理"
data="0">
......