Copy link to clipboard
Copied
I am trying to setup a password that goes from a motion tween to a stationary position where the password_ textfield and username_ textfield are then displayed. From their all I want is "if" the username_.text and password_.text match, gotoAndPlay(16) "else" textBox_.text = "invalid id". Thats it in a nutshell. Where in my script am I going wrong? It says "else is unexpected"? Please help
NOTE: The "id_.text = username_.text is something as just a "Logged in as:" thing, but that has only worked once, then I fiddled with the code some more as when it worked, it wasnt by the name or password, it was just "username_".
//startScript
enter_.addEventListener(MouseEvent.CLICK, loginEnter);
function loginEnter(event:MouseEvent):void {
{
if (username_.text === "Admin" && password_.text === "admin")
if (username_.text === "name" && password_.text === "pass1")
if (username_.text === "name" && password_.text === "pass2")
if (username_.text === "name" && password_.text === "pass3")
if (username_.text === "name" && password_.text === "pass4")
if (username_.text === "name" && password_.text === "pass5")
if (username_.text === "name" && password_.text === "pass6")
if (username_.text === "name" && password_.text === "pass7")
if (username_.text === "name" && password_.text === "pass8")
if (username_.text === "name" && password_.text === "pass9")
gotoAndPlay(16) && id_.text = username_.text
} else {
textBox_.text = "Incorrect ID";
}
}
//endScript
Thanks in advance!
har678
Quote: mr.shumi
//startScript
enter_.addEventListener(MouseEvent.CLICK, loginEnter);
function loginEnter(event:MouseEvent):void {
if((username_.text == "Admin" && password_.text == "admin") || (username_.text =="name" && password_.text == "pass"))
{
id_.text = username_.text;
gotoAndPlay(16);
}
else
{
textBox_.text = "Invalid ID";
}
}
//endScript
Copy link to clipboard
Copied
you should use one if statement and or instead of these i guess and why using ===? instead of == ?
if((username_.text == "Admin" && password_.text == "admin") || (username_.text =="name" && password_.text == "pass1")|| etc )
{
gotoAndPlay(16) && id_.text = username_.text
}
else
{
textBox_.text = "Incorrect ID";
}
try this
i guess it should work
Copy link to clipboard
Copied
is this what you meant? Or just one line with "or" between the brackets?
//startScript
enter_.addEventListener(MouseEvent.CLICK, loginEnter);
function loginEnter(event:MouseEvent):void {
{
if(username_.text == "Admin" && password_.text == "admin");
} and or {
if(username_.text == "user" && password_.text == "pass");
} and or {
if(username_.text == "user1" && password_.text == "pass1");
} gotoAndPlay(16);
}
//endScript
Copy link to clipboard
Copied
Sorry. I copied and pasted your script and MOST works. All will work up until I hit my button (enter_) which is when its meant to gotoAndPlay(16) and display the username. It does not gotoAndPlay(16) nor display the username. Further help?
Thanks
Copy link to clipboard
Copied
action script takes or as this || u cant write or
you write this || and in the if loop u dont put semi colon
if((username_.text == "Admin" && password_.text == "admin") || (username_.text =="name" && password_.text == "pass1") || (username_.text == "name" && password_.text == "pass2") || ((username_.text == "name" && password_.text == "pass3") ||
you continue like this , get the idea
{
// ur condition goes here
}
else
{
ur condition goes here
}
is this a timeline script ?
Copy link to clipboard
Copied
Yes and it is seperate from the items on the main screen. Unfortunately all is working except the display name (id_.text) and gotoAndPlay(16). I am still tryin to work it out, but if you find a fault in the code below, may you please point it out
//startScript
enter_.addEventListener(MouseEvent.CLICK, loginEnter);
function loginEnter(event:MouseEvent):void {
if((username_.text == "Admin" && password_.text == "admin") || (username_.text =="name" && password_.text == "pass1"))
{
gotoAndPlay(16) && id_.text == "Welcome " + username_.text;
}
else
{
textBox_.text = "Incorrect ID";
}
}
//endScript
enter_ = button
id_ = display name
textBox_ = status textfield
username_ = username textfield
password_ = password textfield
NOTE: The textfields are actually "Classic Text" "Input Text" bars, and the display name is a "Classic Text" "Dynamic Text" bar. They are not "TLF Text"
Copy link to clipboard
Copied
gotoAndPlay(16) && id_.text == "Welcome " + username_.text;
here it should be
id_.text == "Welcome " + username_.text;
gotoAndPlay(16);
what are these ?
enter_ = button
id_ = display name
textBox_ = status textfield
username_ = username textfield
password_ = password textfield
Copy link to clipboard
Copied
They were the details to what they equal.
After fiddling with the code a little more it is finally all working
//startScript
enter_.addEventListener(MouseEvent.CLICK, loginEnter);
function loginEnter(event:MouseEvent):void {
if((username_.text == "Admin" && password_.text == "admin") || (username_.text =="name" && password_.text == "pass"))
{
id_.text = username_.text;
gotoAndPlay(16);
}
else
{
textBox_.text = "Invalid ID";
}
}
//endScript
The problem I was facing is the "id_" and "textBox_" had to be "Dynamic Text" and the "username_" and "password_" had to be TFL Editable. As well as that, the "textBox_.text" and "id_.text" had to have one equal bar (=) instead of the suggested two (==), but all-in-all you helped me very well and I would never have figure that code if it werent for you
Thankyou!
Copy link to clipboard
Copied
Quote: mr.shumi
//startScript
enter_.addEventListener(MouseEvent.CLICK, loginEnter);
function loginEnter(event:MouseEvent):void {
if((username_.text == "Admin" && password_.text == "admin") || (username_.text =="name" && password_.text == "pass"))
{
id_.text = username_.text;
gotoAndPlay(16);
}
else
{
textBox_.text = "Invalid ID";
}
}
//endScript
Copy link to clipboard
Copied
glad that i helped welcome