First of all, as Rin said, there will be an argument error when calling the generate
function.
Secondly, you need to add a KeyboardEvent
(ref) listener in order to receive the keyboard events.
The easiest way to listen to keyboard events is to add the listener to the Stage
(because the KeyboardEvents will bubble to the Stage no matter where they were triggered.) In order to get a reference to the Stage, you need to wait until your MovieClip has been added to the DisplayList (when your instance of myJellyFish
has been added as a child somewhere).
You do this by listening for the Event.ADDED_TO_STAGE
event.
// Your constructor
public function myJellyFish() {
// ...
// Add event listener which will trigger when
// the MovieClip has been added to the DisplayList
this.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
}
protected function handleAddedToStage(e:Event):void {
// Remove event listener since it's no longer needed
this.removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
// You now have a reference to the stage, let's add the KeyboardEvent listener
stage.addEventListener(KeyboardEvent.KEY_DOWN, moreClips);
}
Edit: fixed typo in removeEventListener
.