Adding movie clips while the movie is running

Press the star button to add fish. mcfish is a movie clip of the bubbling fish.

code used:

when the star button is pressed (in the actions panel for the button) what a fish does

n++; // "layer"
var fishnum:String; // each fish must be
fishnum = "fish" + n; // assigned a unique instance name
trace(fishnum); // for debugging
_root.attachMovie("mcfish", fishnum, n);


// where would your variables be initialized?

class fish extends MovieClip {

function fish(){ // constructed at a random location
this._x = Math.floor(Math.random()*400+1);
this._y = Math.floor(Math.random()*400+1);

function onEnterFrame(){// moves up to the right each timestep

TOP GRADE: change the code on the button to randomly choose between 2 different kinds of fish movie clips (they can both use the same .as code to control them) and change the onEnterFrame function of the fish class to make the fish move in random directions (hint: choose 2 random numbers from -5 to +5 as the amount to change x and y by )