Keyboard is not detecting as3
- by Kaoru
i got this problem, when i press 1 in keyboard, the function does not run, even i already declared it.
How do i solve this?
Here is the code:
public function Character()
{
Constant.loaderMario.load(new URLRequest("mario.swf"));
addEventListener(KeyboardEvent.KEY_DOWN, selectingPlayer);
}
private function selectingPlayer(event:KeyboardEvent):void
{
isoTextMario = new Word();
isoTextChocobo = new Word();
if (event.keyCode == Keyboard.NUMBER_1|| event.keyCode == 49)
{
Constant.marioSelected = true;
if (Constant.marioSelected == true)
{
isoTextMario.marioCharacter();
addChild(isoTextMario);
}
}
else if (event.keyCode == Keyboard.NUMBER_2 || event.keyCode == 50)
{
Constant.chocoboSelected = true;
if (Constant.chocoboSelected == true)
{
isoTextChocobo.chocoboCharacter();
addChild(isoTextChocobo);
}
}
}