onClipEvent (load) { this._x = random(550); //sets the horizontal position randomly this._y = random(-400); //sets the y position above the stage speed = random(5)+1; //sets the speed randomly } onClipEvent (enterFrame) { this._y += speed; //moves the enemy downwards if (this.hitTest(_root.head)) { //if the enemy hits the player _root.gotoAndStop(2); //goto the second frame, which will be a gameover screen } if (this._y>=310) { //if the player reaches 10 pixels below the stage this._x = random(550); //randomly set the x, y and speed again. this._y = random(-400); speed = random(5)+1; } }