带验证码的Flex登录窗口实例代码

系统 1384 0
<!-- Feedsky FEED发布代码开始 --> 如果您喜欢这些文章,欢迎点击此处订阅本Blog <!-- FEED自动发现标记开始 --> <link title="RSS 2.0" type="application/rss+xml" href="http://feed.feedsky.com/softwave" rel="alternate"> <!-- FEED自动发现标记结束 --> Blog 订阅

<!--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横幅广告结束-->

本例子是实现了一个网页登录窗口的验证程序,具有验证码功能:
  1. <? xml version = "1.0" encoding = "utf-8" ?>
  2. < mx:Application xmlns:mx = "http://www.adobe.com/2006/mxml" layout = "absolute" creationComplete = "initApp()" >
  3. < mx:states >
  4. <!--新建“index”State-->
  5. < mx:State name = "index" >
  6. <!--移除“登录框”-->
  7. < mx:RemoveChild target = "{panel1}" />
  8. <!--添加新的组件-->
  9. < mx:AddChild position = "lastChild" >
  10. < mx:Label x = "231" y = "174" text = "欢迎来到主页" fontFamily = "Georgia" fontSize = "20" />
  11. </ mx:AddChild >
  12. </ mx:State >
  13. </ mx:states >
  14. < mx:Script >
  15. <![CDATA[
  16. importmx.controls.Alert;
  17. privatefunctioninitApp():void
  18. {
  19. //显示校验码
  20. lblCheckCode.text=GenerateCheckCode();
  21. }
  22. privatefunctionloginHandle():void
  23. {
  24. //空的情况
  25. if(txtUsername.text==""||txtPassword.text=="")
  26. {
  27. Alert.show("请输入完整数据!");
  28. }
  29. else
  30. {
  31. //合法用户
  32. if(txtUsername.text=="Administrator"&&txtPassword.text=="123456"&&txtCheckCode.text.toLocaleLowerCase()==lblCheckCode.text.toLowerCase())
  33. {
  34. currentState="index";
  35. }
  36. //登录失败
  37. else
  38. {
  39. //校验码错误
  40. if(txtCheckCode.text.toLowerCase()!=lblCheckCode.text.toLowerCase())
  41. {
  42. Alert.show("校验码错误!");
  43. //重新生成校验码
  44. lblCheckCode.text=GenerateCheckCode();
  45. }
  46. //用户名或密码错误
  47. else
  48. Alert.show("用户名或密码错误!");
  49. }
  50. }
  51. }
  52. privatefunctionresetHandle():void
  53. {
  54. txtUsername.text="";
  55. txtPassword.text="";
  56. txtCheckCode.text="";
  57. }
  58. //生成随机码
  59. privatefunctionGenerateCheckCode():String
  60. {
  61. //初始化
  62. varran:Number;
  63. varnumber:Number;
  64. varcode:String;
  65. varcheckCode:String="";
  66. //生成四位随机数
  67. for(vari:int=0;i<4;i++)
  68. {
  69. //Math.random生成数为类似为0.1234
  70. ran=Math.random();
  71. number=Math.round(ran*10000);
  72. //如果是2的倍数生成一个数字
  73. if(number%2==0)
  74. //"0"的ASCII码是48
  75. code=String.fromCharCode(48+(number%10));
  76. //生成一个字母
  77. else
  78. //"A"的ASCII码为65
  79. code=String.fromCharCode(65+(number%26));
  80. checkCode+=code;
  81. }
  82. returncheckCode;
  83. }
  84. ]]>
  85. </ mx:Script >
  86. < mx:Panel x = "337.5" y = "261" width = "349" height = "257" layout = "absolute" title = "用户登录" fontFamily = "Georgia" fontSize = "12" id = "panel1" >
  87. <!--"用户名"标签-->
  88. < mx:Label x = "41.5" y = "33" text = "用户名" />
  89. <!--"密码"标签-->
  90. < mx:Label x = "42.5" y = "81" text = "密码" />
  91. <!--"用户名"输入框-->
  92. < mx:TextInput x = "94.5" y = "33" id = "txtUsername" />
  93. <!--"密码"输入框-->
  94. < mx:TextInput x = "95.5" y = "81" id = "txtPassword" displayAsPassword = "true" />
  95. <!--"登录"按钮-->
  96. < mx:Button x = "82.5" y = "159" label = "登录" id = "btnLogin" click = "loginHandle()" />
  97. <!--"重置"按钮-->
  98. < mx:Button x = "181.5" y = "159" label = "重置" id = "btnReset" click = "resetHandle()" />
  99. <!--"校验码"标签-->
  100. < mx:Label x = "165.5" y = "125" id = "lblCheckCode" width = "42.5" color = "#377CD0" />
  101. < mx:LinkButton x = "216" y = "123" label = "看不清楚?" id = "linkbtnReGenerate" click = "lblCheckCode.text=GenerateCheckCode();" fontFamily = "Georgia" fontSize = "11" />
  102. < mx:Label x = "39.5" y = "123" text = "校验码" />
  103. <!--"校验码"输入框-->
  104. < mx:TextInput x = "96.5" y = "121" id = "txtCheckCode" width = "61" maxChars = "4" />
  105. </ mx:Panel >
  106. </ mx:Application >
转自: 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&amp;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发布代码结束 -->

带验证码的Flex登录窗口实例代码


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论