Ok what I have is a simple if else script, can anyone help to improve it for a login?

Ok what I am after is a few usernames and passwords in order to access the map I have built.

I have used a simple if else statement, but would really like some direction to further process.

Another cool thing I would like to add is maybe a tick, if correct username has been added, then display tick else dont, the same for password.


on (release) {
	if (pass == "c9804321") {
	gotoAndStop(2);
	    } else {
	gotoAndStop(1);
   }
}

Any help in this area ?

Trev

Ok I have improved it a little but still require the extra stuff. So far I now have :



on (release, keyPress "<Enter>") {
        if (password == "Trevor") {
                gotoAndPlay(2);
        } else if (password == "Martin") {
                gotoAndPlay(2);
        } else if (password == "Adrian") {
                gotoAndPlay(2);
        } else if (password == "Ian") {
                gotoAndPlay(2);
                }
        else {
                gotoAndStop(1);
     }
}


Personally i would use php-mysql-flash.

Anywayz, what about the use of a array?

Something like, haven’t test this (been awhile i use AS) but i think you get the meaning. Some AS-gurus will help you out i think

pwdArray = [“Trevor”, “Martin”,“Adrian”,“Ian”]; //here you can add pwds
on (release, keyPress “<Enter>”) {
for(i=0; i <= pwdArray.length; i++) {
if (password == pwdArray*) {
gotoandplay(2);
}//end if
}//end for

}//end on

Thats great, There is also a username section to the login, how would I go about applying the two together? any ideas and thnx for the reply

T

To combine the two use a variable that is set to “true” when password checks out, and then do the same thing for username. Then write another if statement to see if both new variables are true. If they are…gotoandplay(2). Good luck

Sounds good can you show me a sample of such a connection, as the username goes with the password for each login. If that makes sense. If you have chance please a sample of a typical script would be gr8

Cheers

this is waht u want basically not to complicated for u to understand i suppose basics of as but for the best usabilty a server would be good asp or php

Thank you thats right what I wanted was the ‘and’ fucntion applied also, I will have a good look at this, Yes I really do need to get my head down and understand basics of the if statement etc, and other for that fact.

I started off with this


stop();
//General
	user.type = "input";
	pass.type = "input";
	pass.password = true;


//Setting the fields blank at run time
	user.text = ("");
	pass.text = ("");

//Setting the focus for a field
	Selection.setFocus(user);

This basically set my focus but also set the input boxes to default on retry, which is what I wanted :slight_smile:

The for the button as, i added the following:


on (release, keyPress "<Enter>") {
	if (password == "Trevor") {
		gotoAndPlay(2);
		
	} else if 
	   (password == "Martin") {
		gotoAndPlay(2);
		
	} else if 
	   (password == "Adrian") {
		gotoAndPlay(2);
		
	} else if 
	   (password == "Ian") {
		gotoAndPlay(2);
		
	} else {
		gotoAndStop(1);
		briefText.text = ("Username and password incorrect, please try again.");
		Selection.setFocus(user);
		user.text = ("");
		pass.text = ("");
	}
}

So all I need to do is apply the and etc to get it working, yes I agree php, or in my case asp, would be better to apply it, but with this being internal would it be a problem, keeping it like this, as its not going to be made available to others online, but internal.

And I dont think people who work there are confident enough to do much harm if they wanted to :slight_smile:

Thnx for the file, I will see if I can apply it as I am aiming to do.

Cheers

T

Job done.

Thanks for your help.