Reputation: 887
Okay, so I have this class that basically acts as a manager of an enemy. For some reason, whenever I try to make a bullet instance within the class and use addChild(), I get Error #1009. Here's the code:
var bullet:EnemyBullet = new EnemyBullet();
stage.addChild(bullet); //Error comes up here
bullet.x = enemy.x;
bullet.y = enemy.y;
bManager.bulletVector.push(bullet);
I've been using this method for two other classes without issue, so I'm stuck. All help is appreciated.
Upvotes: 0
Views: 75
Reputation: 35734
I'm guessing because the class does not know where the stage is
the way to handle that would be to use anAddedToStage event handler, and put the stage.addChild
code within
Upvotes: 1