Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. package Classes
  2. {
  3. import fl.controls.Button;
  4. import flash.text.TextField;
  5. import fl.controls.TextInput;
  6. import fl.controls.List;
  7. import fl.motion.MotionEvent;
  8. import flash.events.MouseEvent;
  9. import flash.display.MovieClip;
  10. import flash.display.Stage;
  11. import Classes.InputManager;
  12.  
  13. public class State1 extends State
  14. {
  15. var bLoginCorrect:Boolean = false;
  16.  
  17. /*
  18. Function Description: This function inititalizes the values
  19. once the level starts and displays
  20. "Level1 Constructor".
  21.  
  22. Parameters:
  23. - None
  24. */
  25. public function State1(sStage:Stage)
  26. {
  27. // constructor code
  28. trace ("Level1 Constructor");
  29. super(sStage);
  30. Initialize();
  31.  
  32. }
  33.  
  34. /*
  35. Function Description: This function displays "Level1 Initialized"
  36. when the level is initialized.
  37.  
  38. Parameters:
  39. - None
  40. */
  41. override public function Initialize()
  42. {
  43. trace("Level1 Initialized");
  44.  
  45.  
  46. var buttonLOGIN:Button = new Button;
  47. buttonLOGIN.label = "LOGIN";
  48. buttonLOGIN.x = 350;
  49. buttonLOGIN.y = 310;
  50. buttonLOGIN.width = 350;
  51. sLevelStage.addChild(buttonLOGIN);
  52.  
  53. buttonLOGIN.addEventListener(MouseEvent.MOUSE_DOWN, LOGIN);
  54.  
  55. function LOGIN(m:MouseEvent)
  56. {
  57. if(userName.text != "admin" || userPass.text != "digipen")
  58. {
  59. ClearInput();
  60. }
  61.  
  62. else
  63. {
  64. bLoginCorrect = true;
  65. Update();
  66. trace("hello");
  67. }
  68. }
  69.  
  70. function ClearInput()
  71. {
  72. sLevelStage.addChild(WrongNP);
  73.  
  74. userName.text = "";
  75. userPass.text = "";
  76.  
  77. sLevelStage.addChild(userName);
  78. sLevelStage.addChild(userPass);
  79. }
  80.  
  81. var WrongNP:TextField = new TextField();
  82. WrongNP.text = "Wrong username or password";
  83. WrongNP.x = 450;
  84. WrongNP.y = 200;
  85. WrongNP.width = 200;
  86.  
  87. var userName:TextInput = new TextInput;
  88. userName.x = 450;
  89. userName.y = 230;
  90. userName.width = 250;
  91. userName.restrict = "A-Za-z0-9";
  92. sLevelStage.addChild(userName);
  93.  
  94. var userPass:TextInput = new TextInput;
  95. userPass.x = 450;
  96. userPass.y = 270;
  97. userPass.width = 250;
  98. userPass.displayAsPassword = true;
  99. userPass.restrict = "A-Za-z0-9";
  100. sLevelStage.addChild(userPass);
  101.  
  102. var UName:TextField = new TextField();
  103. UName.text = "Username";
  104. UName.x = 350;
  105. UName.y = 230;
  106. sLevelStage.addChild(UName);
  107.  
  108. var UPass:TextField = new TextField();
  109. UPass.text = "Password";
  110. UPass.x = 350;
  111. UPass.y = 270;
  112. sLevelStage.addChild(UPass);
  113.  
  114. }
  115.  
  116. /*
  117. Function Description: This function allows players to switch
  118. to level 2, restart the game, and exit
  119. the game depending on which key they
  120. press. This will also display "Level1
  121. Updated".
  122.  
  123. Parameters:
  124. - None
  125. */
  126. override public function Update()
  127. {
  128. //if(State1.bLoginCorrect == true)
  129. //{
  130. GameStateManager.iNextState = -2;
  131. //}
  132. //Go to level2
  133.  
  134. }
  135.  
  136. /*
  137. Function Description: This function displays "Level1 Uninitialized"
  138. when the level is uninitialized.
  139.  
  140. Parameters:
  141. - None
  142. */
  143. override public function Uninitialize()
  144. {
  145. trace("Level1 Uninitialized");
  146. }
  147.  
  148. /*
  149. Function Description: This function displays "Level1 Destoryed"
  150. when the level is destroyed.
  151.  
  152. Parameters:
  153. - None
  154. */
  155. override public function Destroy()
  156. {
  157. Uninitialize();
  158. trace("Level1 Destroyed");
  159. }
  160.  
  161. }
  162.  
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement