Fight game with AI

I’ve been looking through the forums and tutorials becuase I really suck in AI scripts so basicly I been trying to find one that would fit my situation. I was wondering if I could have some assistance?

I am using Macromedia flash MX 2004 or 6 either way.

The game is a fighting game I have so far written the script for Player1 it works great and I have added collision and many more. I have setup my character so that it was more simple to use and to understand.

It was set up so that you would see the characters movieclip then when you open it up theres 3 key frames 1st for Idle 2nd for walk (set up to walk both ways) 3rd for attack. If I were to add more keyframes I would have to set it up so that the actionscript would play the frame on a key push simple enough…

Now my problem is that I am doing the same with enemy but I am not using a script where I controll it. I want to make it so that it would follow me with rules of course and when I stoped it would attack. But seeing as I’m no good perhaps someone could help me out abit so that I can basicly.

If I run he would follow and attack me if he was close enough to hit me.
I do want rules applied so that he walks same speed and he does not fly or jump.

I’m not sure if I’m going about this the wrong way but if I could have help to further this project I would sure appreciate it.

This is player 1 code.

onClipEvent (load) {
    fight = false;
}
onClipEvent (enterFrame) {
    if (hitTest(_root.bottom_wall) == true) {
        _y = _root.bottom_wall._y-_root.Player_1_Start._height;
  // Ok this is to make sure my character will never go off map it will stay in the border  
}
    if (hitTest(_root.top_wall) == true) {
        _y = _root.top_wall._y+13.3;
        //This is the same thing just setting the border. I do not need this as much so I just put bad script into this.
    }
    if (hitTest(_root.left_wall) == true) {
        _x = _root.left_wall._x+30;
    // These are my main wall collision scripts. It's basicly telling the player 1 that he will not pass a certain point on the wall he will just stop
}
    if (hitTest(_root.right_wall) == true) {
        _x = _root.right_wall._x-30;
    // These are my main wall collision scripts. It's basicly telling the player 1 that he will not pass a certain point on the wall he will just stop
}
    if (fight == false) {
        if (Key.isDown(Key.LEFT) && fight != true) {
            this._x -= 4;
            this._xscale = -100;
            this.gotoAndStop(2);
        } else if (Key.isDown(Key.RIGHT) && fight != true) {
            this._x += 4;
            this._xscale = 100;
            this.gotoAndStop(2);
        } else {
            this.gotoAndStop(1);
        // This is the fight sequence if the character is not doing anything it will play frame 1 if you hitting a key it will do what it is set to do. below is the script to fight.
}
    }
    if (this._currentframe == 1) {
        fight = false;
        if (Key.isDown(Key.Control)) {
            this.gotoAndStop(3);
            fight = true;
        }
    }
}