I am making a game where my rocket ship has to avoid asteroids. However, my rocket ship sprite will not display. Any helps is appreciated.
var myRocket:MovieClip;
addChild(myRocket);
myRocket.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
myRocket.addEventListener(KeyboardEvent.KEY_UP, keyUp);
myRocket.x=200;
myRocket.y=150;
Ok, that's how you instantiate things from Library.
First, the Library object must have an AS3 class. You assign it in the Library object's properties. Let's say the class name is SpaceRocket.
Then you do the following:
Also, I don't recommend listening the rocket for the keyboard events. It means the rocket should have the keyboard focus, which can be lost quite easily. You should rather listen it at the stage because all the keyboard events go there eventually: