# Enemy AI: Flip Problem

**URL:** <https://forum.kirupa.com/t/enemy-ai-flip-problem/165152>\
**Category:** programming\
**Created:** [October 8, 2005, 6:37am UTC](https://forum.kirupa.com/t/enemy-ai-flip-problem/165152 "2005-10-08T06:37:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![enzeke](https://avatars.discourse-cdn.com/v4/letter/e/e36b37/32.png) [@enzeke](https://forum.kirupa.com/u/enzeke)\
**Post date:** [October 8, 2005, 6:37am UTC](https://forum.kirupa.com/t/enemy-ai-flip-problem/165152/1 "2005-10-08T06:37:11Z")

</div>

how do i make the enemy flip horizontally to the side where his moving …  
i cant find anything that could help me…

```auto
  onClipEvent (enterFrame) {
 _parent.timer++;
 if (moveleft) {
  _parent._x -= _parent.movespeed;
  if (_parent._x<-14) {
   moveleft = false;
   trace("moving right");
  }
 } else {
  _parent._x += _parent.movespeed;
  _parent._xscale *= -1
  if (_parent._x>300) {
   moveleft = true;
   trace("moving left");
  }
 }
 if (_parent.timer>=_parent.holdtime) {
  randomMovement = random(2);
  if (randomMovement == 0) {
   _parent.gotoAndPlay("standup");
  } else {
   _parent.gotoAndPlay("fire");
  }
 }
}

```
