Help needed with my actionscript for scrolling game

hey, asked something similar a while back but I simplified the code to try and get my head round it, relatively new to flash so would appreciate help :slight_smile:

I’ve been trying to make randomly scrolling terrain but I need “points” to go back to the other end of the screen when they go off but I can’t seem to work it out.

I know there are loads of peeps on here who could do it in a few seconds :slight_smile:

cheers and here is the code, feel free to play around with it and try to fix it :wink:

(goes in first frame)

one = function(){
scenewidth = 550;
points = 40;
x = 0;
y = Math.random()*400;
terrain.moveTo(x, y)

for ( var i=0; i < points; i ++ ){
t = createEmptyMovieClip("terrain"+i, i);
t.lineStyle(5, 0x000000, 100)
t.moveTo(x, y);
t.lineTo(x+scenewidth/points, y)
x+=scenewidth/points
y+=Math.random()*20-10
t.onEnterFrame = move;
}
}
move = function(){
this._x-=1;

/*/when they get to less than 0; I need them to move to 550 (the end)
with the y height being within Math.random()*20-10 of the previous y;

like:    

if(this._x < 0){
	this._x = 550;
	this._y = 5;
}
then calculate new y variable, but it doesn't work, it moves
all of the "t"'s to 550 :(
/*/
}
	


one();