Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Classes
- {
- import fl.controls.Button;
- import flash.text.TextField;
- import fl.controls.TextInput;
- import fl.controls.List;
- import fl.motion.MotionEvent;
- import flash.events.MouseEvent;
- import flash.display.MovieClip;
- import flash.display.Stage;
- import Classes.InputManager;
- public class State1 extends State
- {
- var bLoginCorrect:Boolean = false;
- /*
- Function Description: This function inititalizes the values
- once the level starts and displays
- "Level1 Constructor".
- Parameters:
- - None
- */
- public function State1(sStage:Stage)
- {
- // constructor code
- trace ("Level1 Constructor");
- super(sStage);
- Initialize();
- }
- /*
- Function Description: This function displays "Level1 Initialized"
- when the level is initialized.
- Parameters:
- - None
- */
- override public function Initialize()
- {
- trace("Level1 Initialized");
- var buttonLOGIN:Button = new Button;
- buttonLOGIN.label = "LOGIN";
- buttonLOGIN.x = 350;
- buttonLOGIN.y = 310;
- buttonLOGIN.width = 350;
- sLevelStage.addChild(buttonLOGIN);
- buttonLOGIN.addEventListener(MouseEvent.MOUSE_DOWN, LOGIN);
- function LOGIN(m:MouseEvent)
- {
- if(userName.text != "admin" || userPass.text != "digipen")
- {
- ClearInput();
- }
- else
- {
- bLoginCorrect = true;
- Update();
- trace("hello");
- }
- }
- function ClearInput()
- {
- sLevelStage.addChild(WrongNP);
- userName.text = "";
- userPass.text = "";
- sLevelStage.addChild(userName);
- sLevelStage.addChild(userPass);
- }
- var WrongNP:TextField = new TextField();
- WrongNP.text = "Wrong username or password";
- WrongNP.x = 450;
- WrongNP.y = 200;
- WrongNP.width = 200;
- var userName:TextInput = new TextInput;
- userName.x = 450;
- userName.y = 230;
- userName.width = 250;
- userName.restrict = "A-Za-z0-9";
- sLevelStage.addChild(userName);
- var userPass:TextInput = new TextInput;
- userPass.x = 450;
- userPass.y = 270;
- userPass.width = 250;
- userPass.displayAsPassword = true;
- userPass.restrict = "A-Za-z0-9";
- sLevelStage.addChild(userPass);
- var UName:TextField = new TextField();
- UName.text = "Username";
- UName.x = 350;
- UName.y = 230;
- sLevelStage.addChild(UName);
- var UPass:TextField = new TextField();
- UPass.text = "Password";
- UPass.x = 350;
- UPass.y = 270;
- sLevelStage.addChild(UPass);
- }
- /*
- Function Description: This function allows players to switch
- to level 2, restart the game, and exit
- the game depending on which key they
- press. This will also display "Level1
- Updated".
- Parameters:
- - None
- */
- override public function Update()
- {
- //if(State1.bLoginCorrect == true)
- //{
- GameStateManager.iNextState = -2;
- //}
- //Go to level2
- }
- /*
- Function Description: This function displays "Level1 Uninitialized"
- when the level is uninitialized.
- Parameters:
- - None
- */
- override public function Uninitialize()
- {
- trace("Level1 Uninitialized");
- }
- /*
- Function Description: This function displays "Level1 Destoryed"
- when the level is destroyed.
- Parameters:
- - None
- */
- override public function Destroy()
- {
- Uninitialize();
- trace("Level1 Destroyed");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement