Hmm

ok here’s the deal. I want to make this little guy that moves left or right across the screen until he reaches a point which I have told him that he can not pass. At that point I want him to turn around and head the other direction until he reaches the next point that I told him not to pass. this is what i have so far:

onClipEvent(load)
{
//moves enemy to the left
function totheleft()
{
var wierdoSpeed=5;
this._x-=wierdoSpeed;
}
//moves enemy to the right
function totheright()
{
var wierdoSpeed=5;
this._x+=wierdoSpeed;
}
}
onClipEvent(enterFrame)
{
var mymaxleft=10, mymaxright=350;
if(this._x>mymaxleft)
totheleft();

With this code the guy goes to the left and stops at x=10, success, but now I’m not sure where to go from here to make him head back to x=350.


onClipEvent(load){
   max = 350;
   min = 10;
   speed = 5;
   function left(){
      if((this._x -= this.speed) < this.min){
         this.onEnterFrame = right;
      }
   }
   function right(){
      if((this._x += this.speed) > this.max){
         this.onEnterFrame = left;
      }
   }
   this.onEnterFrame = right;
}