Skip navigation
har678
Currently Being Moderated

Is my script wrong somewhere?

Mar 21, 2012 2:07 AM

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

 
Replies
  • Currently Being Moderated
    Mar 21, 2012 2:15 AM   in reply to har678

    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


     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2012 2:33 AM   in reply to har678

    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 ?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2012 3:01 AM   in reply to har678

    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


     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2012 3:21 AM   in reply to har678

    glad that i helped welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points