Frames problem in AI controlled enemy

i need help with my code i have some simple AI but the enemy controlled by it isnt working :S instead of playing the frames it stops :S look at my code and help me please.

its a KH2 platform game using sora in final form.


onClipEvent (load) {
	dead = false
	_root.varduskhp = 1001;
}
onClipEvent (enterFrame) {
speed = 4;
    if(_root.finalsora._x > this._x && !dead) {
		left = 0;
		_x += speed;
	} if(_root.finalsora._x < this._x && !dead) {
		left = 1;
	    _x -= speed;
	}
	if(left==0){
		gotoAndPlay(6);
	}else{
		gotoAndPlay(3);
	}