Copy link to clipboard
Copied
Hi
one of my students has an error, and I can't see it.
He has a input text box (a), and he's looking to check that the user enters "one". If they get it right, it displays a message in dynamic text box (b)
var x:String = "one";
btn_done.onPress = function(){
if (a.text != x){
b.text="Wrong";
trace(a.text);
}
else{
b.text = "Right";
}
}
No matter what one types, the response is "wrong". I've spent hours looking, but can't see the problem. Can anyone shed some light please?
change the textfield from multiline to single line.
(when a text trace look like you expect but doesn't act the way you expect, trace its length, too. that will reveal white space problems. in your case you probably have a carriage return at the end of "one". ie, "one\r".)
Copy link to clipboard
Copied
change the textfield from multiline to single line.
(when a text trace look like you expect but doesn't act the way you expect, trace its length, too. that will reveal white space problems. in your case you probably have a carriage return at the end of "one". ie, "one\r".)
Copy link to clipboard
Copied
How do you trace the length?
Copy link to clipboard
Copied
strings have a length property:
var x:String = "one";
btn_done.onPress = function(){
if (a.text != x){
b.text="Wrong";
trace(a.text+" "+a.text.length);
}
else{
b.text = "Right";
}
}
Copy link to clipboard
Copied
Thanks so much for your informative and clear replies
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now