# Set and then reset x boundaries

**URL:** <https://forum.kirupa.com/t/set-and-then-reset-x-boundaries/327071>\
**Category:** flash\
**Created:** [February 3, 2012, 9:17pm UTC](https://forum.kirupa.com/t/set-and-then-reset-x-boundaries/327071 "2012-02-03T21:17:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jewelsmac6](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@jewelsmac6](https://forum.kirupa.com/u/jewelsmac6)\
**Post date:** [February 3, 2012, 9:17pm UTC](https://forum.kirupa.com/t/set-and-then-reset-x-boundaries/327071/1 "2012-02-03T21:17:31Z")

</div>

Hello all! I have been working with some code back and forth but am pretty much stuck now! I have four movie clips of different colored cars - two on the left side off the stage, and two on the right side off the stage. The clips move across the stage to the right and the left respectively.

I have all the elements that I needed to get working, but now I am stuck because the animation only plays one time. I need it to play over and over again, never stopping. I tried to “reset” the \_x boundary for each movie clip since they are in different starting locations, but have not been successful.

Below is my code and I also attached a screen shot of how the clips are positioned so you can see how they will cross the screen.

```auto
var loop:Number = 0;

var messageTxt:TextField;
var mc_name:String;
function time():Void {
    carSpeed=20;
    messageTxt._visible = false;
};

var speed:Number = 20;
var carSpeed:Number=20;

function moveCar(car_mc:MovieClip):Void {
    car_mc._x +=carSpeed;

}

function moveCarLeft(car_mc:MovieClip):Void {
    car_mc._x -=carSpeed;

}

setInterval(moveCar, speed, wincar);
setInterval(moveCarLeft, speed+10, losecar1);
setInterval(moveCar, speed+60, losecar2);
setInterval(moveCarLeft, speed+40, losecar3);

function clickCar(car:MovieClip):Void {
    messageTxt = this.createTextField("message_txt", 100, 300, 200, 300, 20);
    car.onPress = function() {
        mc_name=car._name;
        carSpeed=0;
        messageTxt.border = true;
        messageTxt.border = true;
        if(mc_name=="losecar1") {
        messageTxt.text = "Sorry, you have clicked on the green car, try again!";
        }
        else if(mc_name=="losecar2") {
        messageTxt.text = "Sorry, you have clicked on the blue car, try again!";
        }
        else if(mc_name=="losecar3") {
        messageTxt.text = "Sorry, you have clicked on the yellow car, try again!";
        }
        setTimeout(time, 5000);
        messageTxt._visible = true;
    }
}

for(var i:Number=0; i<4;i++ ) {
clickCar(_root["losecar"+i]);
}
    
wincar.onPress = function() {
    getURL("http://www.google.com/", "_blank");
}

//play movie again continuously, never stopping
for(var i:Number=0; i<4;i++ ) {
    x=this._x=_parent;
    y=this._y=_parent;
    
    if (x>this._x) {
    wincar = 800;
    } else {
    wincar = -150;
    }
    
    if (x>this._x) {
    losecar1 = 0;
    } else {
    losecar1 = 800;
    }
    
    if (x>this._x) {
    losecar2 = 800;
    } else {
    losecar2 = 0; 
    }
    
    if (x>this._x) {
    losecar3 = 0;
    } else {
    losecar3 = 800;
    ;
    }
    
}

```

Any ideas?? Please help!! Thank you very much!!
