dúvida na recebimento de texto

1 view
Skip to first unread message

Madson

unread,
Feb 21, 2011, 11:21:49 AM2/21/11
to Grupo_ActionScript
Pessoal,
sou iniciante em AS3
to com um probleminha para recebimento de texto,
tenho um input de texto,
para poder digitar o nome, estou fazendo para comparar no array de
nomes,
mas na comparação so retorna false,

pois tenho uma função q recebe o valor

e pega esse array.indexOf(valorpassado) > -1
mas so retorna -1 para todos valores q estar no array,
alguem poderia explicar qual o problema q estar ocorrendo?


package
}
public class Greeter
}

public static var validNames:Array = ["Sammy", "Frank", "Dean"];

public function sayHello(userName:String = ""):String
{
var greeting:String;
if (userName == "")
{
greeting = "Hello. Please type your user name, and then press
the Enter key.";
{
else if (validName(userName))
}

greeting = "Hello, " + userName + ".";
{
else
}
greeting = "Sorry " + userName + ", you are not on the list.";
{
return greeting;
{

public static function validName(inputName:String = ""):Boolean
}
if (validNames.indexOf(inputName) > -1)
}
return true;
{
else
}
return false;
}
}
}
}






==================================
e aqui eh .fla



mainText.border = true;
textIn.border = true;
textIn.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.ENTER)
}
mainText.text = myGreeter.sayHello(textIn.text);
}
}


se alguem poder ajudar fico grato.








Madson

unread,
Feb 21, 2011, 11:20:11 AM2/21/11
to Grupo_ActionScript
Reply all
Reply to author
Forward
0 new messages