Altering x position of movie clip dynamically

Hi,

I’ve built a little experiment which lets the user control a car with the fwd and bckwrd arrow keys. the idea is to move the car fwd but if it goes above a certain speed you have to slow it down. I have it working but the way i’ve done it is to move the backround to make it look like the car is moving. However, the backround can only be a certain width so atfer a while is moves clear of the screen. I’m trying to have it so that when the road’s _x coordinate hits a certain point then it will jump back to its original point and the road will look like its just continuously moving. Here is the main code.

[color=blue]onClipEvent (load){
//dir = 0;
speed = 0;
}[/color]
[color=blue]onClipEvent (enterFrame) {
xspeed = Math.cos(dirMath.PI/180)speed;
yspeed = Math.sin(dir
Math.PI/180)speed;
_x += xspeed;
_y += yspeed;
//_rotation = dir; [/color]
[color=blue]if (Key.isDown(Key.RIGHT)) {
speed += -1;
}
if (speed<=0){
if (Key.isDown(Key.LEFT)) {
speed += 1;
}
}
[/color][color=blue][/color]
[color=blue]if (speed<0) {
_root.caption.carspeed = -1
speed;
}
if (speed>=0){
_root.caption.carspeed = 1
speed;
}[/color]
[color=#0000ff][/color]
[color=blue]if (speed<12){
_root.caption.health = “SAFE”;
elseif (speed>=12)
_root.caption.health = “DANGER”;
}[/color]
[color=#0000ff][/color]
[color=black]This is the bit where I tried to get the _x value to change:[/color]
[color=blue][/color]
[color=red]if(_x==(-3104)){
_x =+ 3104;
}[/color]

[color=blue]}[/color]

I’ve attatched my .fla to help explain!
[color=#0000ff][/color]
[color=black]I think i’m totally wrong and would greatly appreciate some help![/color]
:slight_smile: