gotoAndPlay in a class

Hello, I ll try to explain what im trying to do in a game. I spawn a monster on x=500 and he walks with an animation to x=100,(animation loop is from frame 1 to 6), i want to change that animation from frame 8 to 20 (attack animation) then play again the old loop.

In the mc i have one gotoAndPlay(1) on frame 6 and one gotoAndPlay(1) on frame 20

if (this._x > 100) {
            this._x -= 3;
        } else {
            damagetime++;
            if (damagetime== 50) {
                gotoAndPlay(8);
                            }
            if (damagetime== 60) {
                damagetime= 0;
            }
        }

this is how i spawn the monster

{
            var enemyout = _root.attachMovie("enemy1", "enemy1" + _root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:500, _y:random1});
            enemies.push(enemyout);
        }