Friday, June 22, 2012

[Action Script] simple login form June,2012

Hi everyone,

First post on the forum so I hope I'm posting this on the right place. I'm pretty new to AS and I am trying to make a simple login page but.... it's not doing the way I want it to go.

I create 2 input fields nametxt and passtxt, and a login button btn_login (a movie clip)

When I enter the name and password into the fields I get the message incorrect username / password, while I entered the exact information.

Here is the script :
Code: stop();

var cMenu:ContextMenu = new ContextMenu();
cMenu.hideBuiltInItems();
contextMenu = cMenu;


passtxt.displayAsPassword = true;

btn_login.buttonMode = true; // show hand cursor


btn_login.addEventListener(MouseEvent.CLICK, loginUser);

function loginUser(e:MouseEvent):void
{
       
        if(nametxt.text == "admin" && passtxt.text == "password")
        {
                gotoAndPlay(2);
        }else {
                //otherwise show an error message
                var alert:TextFormat = new TextFormat();
                alert.color = 0xff0000; //red font
                display_txt.text = "Incorrect username or password";
                display_txt.setTextFormat(alert);
        }
}Thank you in advance
simple login form

Related Post



0 comments: