create an instace variable (state) to store the enemy state
On line of sight compare the angle from enemy to player angle(enemy.X,enemy.Y,player.X,player.Y) and based on this result, change the enemy.state to running_away_left ... running_away_right
If enemy.state = running_away_right Set enemy.position to Self.X + 1
You need also a condition to stop it and change the enemy.state
This however lends itself for some issue, when the player is turned with his back to the enemy. The enemy would run at the player in this matter..
A simple compare,
Enemy.X < Player.X (enemy is on the left of the player)
Enemy.X > Player.X (enemy is on the right of the player)
Gives you a clear indication on which side the enemey and players are, run away appropiately.