all groups > flash actionscript > november 2006 >
You're in the

flash actionscript

group:

Actionscript Problem



Actionscript Problem Steele Imaging
11/18/2006 11:02:46 PM
flash actionscript: Folks,
I have a simple username / password script.

Here it is:
---------------------------------------------------------------
on (press, keyPress "<Enter>") {
limitu = username.length;
limitp = password.length;
trace(limitu);
trace(limitp);
for (i=0; i<limitu; i++) {
trace(i);
if (usernameInput == username[i] && passwordInput == password[i]) {
// in message window, show access granted.
trace("granted.");
_root.message_window.gotoAndPlay("grant");
getURL(destiny[i], "_self");
trace(destiny[i]);
_root.user_txt.setFocus();
break;
} else {
// in message window, show access denied.
trace("denied.");
_root.user_txt.setFocus();
usernameInput = "";
passwordInput = "";
_root.message_window.gotoAndPlay("deny");
}
// end of if
}
// end of for
}
// end of on
-------------------------------------------

Here is the ActionScript code that is being loaded...

--------------------------------------
// ** MULTIPLE USERS, DESTINATION EDITION
// ******************************************************************
username = new Array();
password = new Array();
destiny = new Array();
// ** username 1 matches with password 1 ^_^
username[0] = "user1";
password[0] = "user1";
destiny[0] = "http://audio.steeleimaging.com/CLIENT/destination.html";
//
username[1] = "user2";
password[1] = "user2";
destiny[1] = "http://audio.steeleimaging.com/CLIENT/destination.html";
//
username[2] = "user3";
password[2] = "user3";
destiny[2] = "http://audio.steeleimaging.com/CLIENT/destination.html";
//
username[3] = "user4";
password[3] = "user4";
destiny[3] = "http://audio.steeleimaging.com/CLIENT/destination.html";
//
username[4] = "user5";
password[4] = "user5";
destiny[4] = "http://audio.steeleimaging.com/KFGE/sicas.html";
//
username[5] = "user6";
password[5] = "user6";
destiny[5] = "http://audio.steeleimaging.com/CLIENT/destination.html";
//

--------------------------------------------------------------------------------
---

When I test the movie, and trace the actionscript file, I can see that all of
the script information is loaded in. However, when I enter the credential
information, only USER1 is validated. Anything past USER1 wont work..

Help?
Re: Actionscript Problem Steele Imaging
11/19/2006 12:00:00 AM
That is correct. It should check ALL items from the array and if none are founf
trigger the denied message. I have just disabled the
_root.message_window.gotoAndPlay("deny");
line and still it will not work...


Re: Actionscript Problem kglad
11/19/2006 12:00:00 AM
try:



on (press, keyPress "<Enter>") {
limitu = username.length;
limitp = password.length;
trace(limitu);
trace(limitp);
loginMatch = 0;
for (i=0; i<limitu; i++) {
trace(i);
if (usernameInput == username[i] && passwordInput == password[i]) {
loginMatch = 1;
}
}
if (loginMatch) {
// in message window, show access granted.
trace("granted.");
_root.message_window.gotoAndPlay("grant");
getURL(destiny, "_self");
trace(destiny);
_root.user_txt.setFocus();
break;
} else {
// in message window, show access denied.
trace("denied.");
_root.user_txt.setFocus();
usernameInput = "";
passwordInput = "";
_root.message_window.gotoAndPlay("deny");
}
}
Re: Actionscript Problem kglad
11/19/2006 2:07:16 AM
anything that fails to match the first element of your arrays will trigger your
_root.message_window.gotoAndPlay("deny"); statement. you probably only want to
trigger that if there's no match with any of the array elements, correct?
AddThis Social Bookmark Button