Skip to main content
Participant
December 21, 2008
Question

Trouble with IF

  • December 21, 2008
  • 3 replies
  • 566 views
Hi,

I am having trouble with the 'if' statement. Whenever I try to use 'if' for input text it doesn't work. EX. I make an input box and give it a var name of userInput. then i'll code:

if (userInput == 350){
output = "You just entered three fifty!";
} else {
output = "Cool";
}

but it won't work. what am i doing wrong?
This topic has been closed for replies.

3 replies

zeropsAuthor
Participant
December 21, 2008
I don't actually get an actionscript error it just doesn't pay any attention to my 'if' it just will do what the 'else' commands.
Inspiring
December 21, 2008
whats the error?
Inspiring
December 21, 2008
You should avoid using variable names for text fields. Instead give them a
regular instance name, and access the text through the text property of the
instance. So erase get rid of the var and change the instance to userInput -
then:

if(userInput.text == "350"){
output.text = "you entered 350";
}else{
output.text = "cool";
}

--
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


zeropsAuthor
Participant
December 21, 2008
quote:

Originally posted by: Newsgroup User
You should avoid using variable names for text fields. Instead give them a
regular instance name, and access the text through the text property of the
instance. So erase get rid of the var and change the instance to userInput -
then:

if(userInput.text == "350"){
output.text = "you entered 350";
}else{
output.text = "cool";
}

--
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/





i tried that and it didn't work for me. I don't know what i'm doing wrong.

December 22, 2008
Since you sar var name rather than instance name in your post, try:

if(userInput == "350"){
output.text = "you entered 350";
}else{
output.text = "cool";
}

In other words, leave off the .text