Madson
unread,Feb 21, 2011, 11:21:49 AM2/21/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.