Guest User

Untitled

a guest
Jan 18th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. function login_check (e:MouseEvent):void {
  2.  
  3. /*
  4. check fields before sending request to php
  5. */
  6.  
  7. if (login_username.text == "" || login_password.text == "") {
  8.  
  9. /*
  10. if username or password fields are empty set error messages
  11. */
  12.  
  13. if (login_username.text == "") {
  14.  
  15. login_username.text = "Enter your username";
  16.  
  17. }
  18.  
  19. if (login_password.text == "") {
  20.  
  21. login_password.text = "Enter your password";
  22.  
  23. }
  24.  
  25. } else {
  26.  
  27. /*
  28. init function to process login
  29. */
  30.  
  31. login_process();
  32.  
  33. }
  34.  
  35. }
  36.  
  37. /*
  38. function to process our login
  39. */
  40.  
  41. function login_process ():void {
  42.  
  43. /*
  44. variables that we send to the php file
  45. */
  46.  
  47. var phpVars:URLVariables = new URLVariables();
  48.  
  49. /*
  50. we create a URLRequest variable. This gets the php file path.
  51. */
  52.  
  53. var phpFileRequest:URLRequest = new URLRequest("php/controlpanel.php");
  54.  
  55. /*
  56. this allows us to use the post function in php
  57. */
  58.  
  59. phpFileRequest.method = URLRequestMethod.POST;
  60.  
  61. /*
  62. attach the php variables to the URLRequest
  63. */
  64.  
  65. phpFileRequest.data = phpVars;
  66.  
  67. /*
  68. create a new loader to load and send our urlrequest
  69. */
  70.  
  71. var phpLoader:URLLoader = new URLLoader();
  72. phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  73. phpLoader.addEventListener(Event.COMPLETE, login_result);
  74.  
  75. /*
  76. now lets create the variables to send to the php file
  77. */
  78.  
  79. phpVars.systemCall = "login_check";
  80. phpVars.login_username = login_username.text;
  81. phpVars.login_password = login_password.text;
  82.  
  83. /*
  84. this will start the communication between flash and php
  85. */
  86.  
  87. phpLoader.load(phpFileRequest);
  88.  
  89. }
  90.  
  91. /*
  92. function to show the result of the login
  93. */
  94.  
  95. function login_result (event:Event):void {
  96.  
  97. /*
  98.  
  99. this autosizes the text field
  100.  
  101. ***** You will need to import flash's text classes. You can do this by:
  102.  
  103. import flash.text.*;
  104.  
  105. */
  106.  
  107. login_result_text.autoSize = TextFieldAutoSize.LEFT;
  108.  
  109. /*
  110. this gets the output and displays it in the result text field
  111. */
  112.  
  113. if (event.target.data.login_result == "1") {
  114. login_result_text.text = "Login In...";
  115. this.gotoAndStop("login_loggedin");
  116. }else{
  117. login_result_text.text = "Username and password doesn't match.";
  118. }
  119.  
  120. }
  121.  
  122. print "login_registration_status=1";
Add Comment
Please, Sign In to add comment