I’m new in ActionScript, and I’m trying to make my first application. I have a main class – subclass of Sprite. and another one class, wich should manage some evnts, like keyboard’s key pressing. Here is it’s initialisation:
private var controller:GameObjectController;
...
controller = new GameObjectController(this);
Here is controller:GameObjectController itself:
public class GameObjectController extends InteractiveObject
{
var textField:TextField;
public function GameObjectController(mainSprite: Sprite)
{
addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
textField = new TextField();
textField.text = "Hello, World";
mainSprite.addChild(textField);
}
private function onKeyDown(event: KeyboardEvent):void
{
textField.text = event.keyCode.toString();
}
}
but when I’m trying to run this, I have an error:
ArgumentError: Error #2012: Class GameObjectController$ can not be
created.
What am I doing wrong?
From the docs: InteractiveObject
So I would suggest trying to subclass Sprite instead and see if that fixes your problem.