MeanMufassa
06-01-2010, 01:00 AM
Hello! I just started trying to learn action script a day or two ago, and was basically teaching myself through the help files. I was trying to do this tutorial
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fdf.html
Basically it asks for a name and then checks the name against a list. For some reason the check always fails, though. I tried changing the if statement to "if (validNames[0]=="Bob")" and it works, but "if(validNames[0]==inputName) doesn't when I type in "Bob" to the text box.
public static function validName(inputName:String = ""):Boolean
{
if (validNames.indexOf(inputName) > -1)
{
return true;
}
else
{
return false;
}
}
The code that reads the text in is...
textIn.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.ENTER)
{
mainText.text = myGreeter.sayHello(textIn.text);
}
}
Anyway I have no idea why it's not working at this point. Thanks a lot in advance for any help, and sorry if I shoved too much/little information in here. Like I said, I'm horribly new.
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fdf.html
Basically it asks for a name and then checks the name against a list. For some reason the check always fails, though. I tried changing the if statement to "if (validNames[0]=="Bob")" and it works, but "if(validNames[0]==inputName) doesn't when I type in "Bob" to the text box.
public static function validName(inputName:String = ""):Boolean
{
if (validNames.indexOf(inputName) > -1)
{
return true;
}
else
{
return false;
}
}
The code that reads the text in is...
textIn.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.ENTER)
{
mainText.text = myGreeter.sayHello(textIn.text);
}
}
Anyway I have no idea why it's not working at this point. Thanks a lot in advance for any help, and sorry if I shoved too much/little information in here. Like I said, I'm horribly new.