<!-- Feedsky FEED发布代码开始 -->
如果您喜欢这些文章,欢迎点击此处订阅本Blog
<!-- FEED自动发现标记开始 --> <link title="RSS 2.0" type="application/rss+xml" href="http://feed.feedsky.com/softwave" rel="alternate"> <!-- FEED自动发现标记结束 -->
<!--Google 468*60横幅广告开始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "image"; //2007-07-26: CSDN google_ad_channel = "6063905817"; google_color_border = "6699CC"; google_color_bg = "E6E6E6"; google_color_link = "FFFFFF"; google_color_text = "333333"; google_color_url = "AECCEB"; google_ui_features = "rc:6"; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--Google 468*60横幅广告结束-->
本例子是实现了一个网页登录窗口的验证程序,具有验证码功能:
转自:
http://www.joelove.cn/
<!--新Google 468*60横幅广告开始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; /* 468x60, 创建于 08-8-6 */ google_ad_slot = "7368701459"; google_ad_width = 468; google_ad_height = 60; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--新Google 468*60横幅广告结束-->
<!--新Google 468x15 横链接单元开始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; /* 468x15 横链接单元 */ google_ad_slot = "5785741422"; google_ad_width = 468; google_ad_height = 15; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--新Google 468x15 横链接单元结束-->
<!-- Google Reader shared发布代码开始 --><script type="text/javascript" src="http://www.google.com/reader/ui/publisher.js"></script><script type="text/javascript" src="http://www.google.com/reader/public/javascript/user/00697638153916680411/state/com.google/broadcast?n=5&callback=GRC_p%28%7Bc%3A%22green%22%2Ct%3A%22%5Cu8FD9%5Cu4E9B%5Cu6587%5Cu7AE0%5Cu4E5F%5Cu503C%5Cu5F97%5Cu4E00%5Cu770B%22%2Cs%3A%22false%22%7D%29%3Bnew%20GRC"></script><!-- Google Reader shared发布代码结束 -->
<!--Google 468*60横幅广告开始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "image"; //2007-07-26: CSDN google_ad_channel = "6063905817"; google_color_border = "6699CC"; google_color_bg = "E6E6E6"; google_color_link = "FFFFFF"; google_color_text = "333333"; google_color_url = "AECCEB"; google_ui_features = "rc:6"; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--Google 468*60横幅广告结束-->
本例子是实现了一个网页登录窗口的验证程序,具有验证码功能:
- <? xml version = "1.0" encoding = "utf-8" ?>
- < mx:Application xmlns:mx = "http://www.adobe.com/2006/mxml" layout = "absolute" creationComplete = "initApp()" >
- < mx:states >
- <!--新建“index”State-->
- < mx:State name = "index" >
- <!--移除“登录框”-->
- < mx:RemoveChild target = "{panel1}" />
- <!--添加新的组件-->
- < mx:AddChild position = "lastChild" >
- < mx:Label x = "231" y = "174" text = "欢迎来到主页" fontFamily = "Georgia" fontSize = "20" />
- </ mx:AddChild >
- </ mx:State >
- </ mx:states >
- < mx:Script >
- <![CDATA[
- importmx.controls.Alert;
- privatefunctioninitApp():void
- {
- //显示校验码
- lblCheckCode.text=GenerateCheckCode();
- }
- privatefunctionloginHandle():void
- {
- //空的情况
- if(txtUsername.text==""||txtPassword.text=="")
- {
- Alert.show("请输入完整数据!");
- }
- else
- {
- //合法用户
- if(txtUsername.text=="Administrator"&&txtPassword.text=="123456"&&txtCheckCode.text.toLocaleLowerCase()==lblCheckCode.text.toLowerCase())
- {
- currentState="index";
- }
- //登录失败
- else
- {
- //校验码错误
- if(txtCheckCode.text.toLowerCase()!=lblCheckCode.text.toLowerCase())
- {
- Alert.show("校验码错误!");
- //重新生成校验码
- lblCheckCode.text=GenerateCheckCode();
- }
- //用户名或密码错误
- else
- Alert.show("用户名或密码错误!");
- }
- }
- }
- privatefunctionresetHandle():void
- {
- txtUsername.text="";
- txtPassword.text="";
- txtCheckCode.text="";
- }
- //生成随机码
- privatefunctionGenerateCheckCode():String
- {
- //初始化
- varran:Number;
- varnumber:Number;
- varcode:String;
- varcheckCode:String="";
- //生成四位随机数
- for(vari:int=0;i<4;i++)
- {
- //Math.random生成数为类似为0.1234
- ran=Math.random();
- number=Math.round(ran*10000);
- //如果是2的倍数生成一个数字
- if(number%2==0)
- //"0"的ASCII码是48
- code=String.fromCharCode(48+(number%10));
- //生成一个字母
- else
- //"A"的ASCII码为65
- code=String.fromCharCode(65+(number%26));
- checkCode+=code;
- }
- returncheckCode;
- }
- ]]>
- </ mx:Script >
- < mx:Panel x = "337.5" y = "261" width = "349" height = "257" layout = "absolute" title = "用户登录" fontFamily = "Georgia" fontSize = "12" id = "panel1" >
- <!--"用户名"标签-->
- < mx:Label x = "41.5" y = "33" text = "用户名" />
- <!--"密码"标签-->
- < mx:Label x = "42.5" y = "81" text = "密码" />
- <!--"用户名"输入框-->
- < mx:TextInput x = "94.5" y = "33" id = "txtUsername" />
- <!--"密码"输入框-->
- < mx:TextInput x = "95.5" y = "81" id = "txtPassword" displayAsPassword = "true" />
- <!--"登录"按钮-->
- < mx:Button x = "82.5" y = "159" label = "登录" id = "btnLogin" click = "loginHandle()" />
- <!--"重置"按钮-->
- < mx:Button x = "181.5" y = "159" label = "重置" id = "btnReset" click = "resetHandle()" />
- <!--"校验码"标签-->
- < mx:Label x = "165.5" y = "125" id = "lblCheckCode" width = "42.5" color = "#377CD0" />
- < mx:LinkButton x = "216" y = "123" label = "看不清楚?" id = "linkbtnReGenerate" click = "lblCheckCode.text=GenerateCheckCode();" fontFamily = "Georgia" fontSize = "11" />
- < mx:Label x = "39.5" y = "123" text = "校验码" />
- <!--"校验码"输入框-->
- < mx:TextInput x = "96.5" y = "121" id = "txtCheckCode" width = "61" maxChars = "4" />
- </ mx:Panel >
- </ mx:Application >
<!--新Google 468*60横幅广告开始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; /* 468x60, 创建于 08-8-6 */ google_ad_slot = "7368701459"; google_ad_width = 468; google_ad_height = 60; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--新Google 468*60横幅广告结束-->
<!--新Google 468x15 横链接单元开始--><script type="text/javascript"><!-- google_ad_client = "pub-7343546549496470"; /* 468x15 横链接单元 */ google_ad_slot = "5785741422"; google_ad_width = 468; google_ad_height = 15; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><!--新Google 468x15 横链接单元结束-->
<!-- Google Reader shared发布代码开始 --><script type="text/javascript" src="http://www.google.com/reader/ui/publisher.js"></script><script type="text/javascript" src="http://www.google.com/reader/public/javascript/user/00697638153916680411/state/com.google/broadcast?n=5&callback=GRC_p%28%7Bc%3A%22green%22%2Ct%3A%22%5Cu8FD9%5Cu4E9B%5Cu6587%5Cu7AE0%5Cu4E5F%5Cu503C%5Cu5F97%5Cu4E00%5Cu770B%22%2Cs%3A%22false%22%7D%29%3Bnew%20GRC"></script><!-- Google Reader shared发布代码结束 -->