# Moving Characters

**URL:** <https://forum.kirupa.com/t/moving-characters/194879>\
**Category:** programming\
**Created:** [July 26, 2006, 10:06pm UTC](https://forum.kirupa.com/t/moving-characters/194879 "2006-07-26T22:06:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregmax17](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gregmax17/32/2243_2.png) [@gregmax17](https://forum.kirupa.com/u/gregmax17)\
**Post date:** [July 26, 2006, 10:06pm UTC](https://forum.kirupa.com/t/moving-characters/194879/1 "2006-07-26T22:06:13Z")

</div>

Hello, I am trying to make several computer characters move around the screen. I am successful in making them walk back and forth between two locations, but it triggers all characters at once. I am asking if anyone knows what I can do to the script provided below to make them turn around and walk back at different ‘times’ (I guess that is the word to use). here is the script I have so far:

function turnAround(num) {  
villager\_speed = -.3; //ameks the characters walk to the right  
setInterval(walkAround, 4000);  
this[‘villager\_’+num].gotoAndStop(2);  
}

function walkAround(num) {  
villager\_speed = .3; //make them walk to the left  
setInterval(turnAround, 4000, num); //after 4 seconds turn around and walk the other direction  
this[‘villager\_’+num].onEnterFrame = function() {  
this.\_x -= villager\_speed;  
}  
}

for(var v = 1; v \<= 2; v++) { //just two charactesr at the moment  
walkAround(v);  
}

stop();

Any help on making them turn around at any random time would be appreciated. Also, the characters have two frames, one looking left and the other looking right. I have this:

this[‘villager\_’+num].gotoAndStop(2);

to make them face right when they walk to the right, but it doesn’t work…? Please help me with this. Thanks
