So I got a Main Class and Import inside it an Elliptical animation Class each extends Sprite. Everything works with eventListener for MouseEvent. But when I changed it to keyboard event, it stops working!
My Main looks like this
class Main extends Sprite {
var mcElliptical = new Elliptical()
public function new(){
addChild(mcElliptical);
}
}
The working Elliptical class looks like this
class Elliptical extends Sprite {
//private vars lots of it
public function new(){
initializeObjects();
}
private function initializeObjects(){
// Assets bitmap and so on
addEventListener(MouseEvent.MOUSE_DOWN, initializeTween);
}
private function initializeTween(e:MouseEvent){
//many conditions here to lunch tween_0, tween_1, tween_2 and so on.
}
private function tween_01(){
//Several Actuate.tween here
}
.
.
.
}
When I replaced the listener to Keyboard event,
addEventListener(KeyboardEvent.KEY_DOWN, initializeTween);
.
.
.
private function initializeTween(e:KeyboardEvent) ...
it compiles ok, no error but animations was not triggered when I press any keys on my keyboard, no trace output either. When I return it back to mouse event, things animate when I click my mouse, so I was sure that my problem was activating the keyboard event. I dont know what I did wrong, I coded it like any other event does. Any help?
By the way, tried the following with no luck:
stage.addEventListener(KeyboardEvent.KEY_DOWN, initializeTween),
this.addEventListener(KeyboardEvent.KEY_DOWN, initializeTween);
this.parent.addEventListener(KeyboardEvent.KEY_DOWN, initializeTween);
Lib.current.addEventListener(KeyboardEvent.KEY_DOWN, initializeTween);