Keyboard is not detecting as3
Posted
by
Kaoru
on Game Development
See other posts from Game Development
or by Kaoru
Published on 2013-10-27T15:45:10Z
Indexed on
2013/10/27
16:01 UTC
Read the original article
Hit count: 207
actionscript-3
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);
}
}
}
© Game Development or respective owner