If Else statement?

Ooooh I am frustrated- I have the worst luck with If Else statements-

I have a text field- after entering 1234 the user clicks a button that tests their input. The text field is called link1


on (release) {
if (link1 == “1234”) {
trace(“Yessss”);
} else {
trace(“Noooooo”);
}
}


It always defaults to the else action, even when I have 1234 in the text box. WHY?

Thanks for your help!
Tobias

It seems like it should work but again if statements are very very picky so if you don’t mind can you e-mail me the .fla ( [email protected] ) and I’ll fix it nd post an answer but its hard to tell what is wrong without seeing exactly where everything is placed in your movie and its all depending on the text field properties too! Well just send it over and I will fix it really fast!

Just shooting in the dark:

  • check the path to your textbox (90% of errors)
  • check if you gave your text an instance name (not good in this case and only with MX anyway) or a variable name.
  • send the file to Dan

pom :asian:

I looked at your file and realized your mistake that a lot of people also make, you gave your input text box an instance name instead of a variable name which is used for getting results from user input and an instance name is for using the text box and editing it with its object methods (pom knows what I’m talking about but you might not). So just look at my pictures below and thats all you need to know! Simple Mistake means a Simple Fix:

**[color=red]||||||||||[/color] = This should be blank unless you are using the text box as an object and using methods!

[color=green]||||||||||[/color] = This is where you want to put ‘link1’ for what you are trying to do!**

Absolutely, Sir. Actually, you could go round, as Macromedia seems to want to ‘objectize’ everything: you could keep the instance name, but then change the code into

if (link1.text=="1234") //...

Either way works.

pom :asian:

Gosh durn. . . sad thing is I have done that before!!! You think I would learn.

Thanks so much!

Peace,
T