# Help needed with my actionscript for scrolling game

**URL:** <https://forum.kirupa.com/t/help-needed-with-my-actionscript-for-scrolling-game/181468>\
**Category:** Uncategorized\
**Created:** [March 9, 2006, 4:48pm UTC](https://forum.kirupa.com/t/help-needed-with-my-actionscript-for-scrolling-game/181468 "2006-03-09T16:48:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slideth3](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@slideth3](https://forum.kirupa.com/u/slideth3)\
**Post date:** [March 9, 2006, 4:48pm UTC](https://forum.kirupa.com/t/help-needed-with-my-actionscript-for-scrolling-game/181468/1 "2006-03-09T16:48:57Z")

</div>

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 🙂

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 🙂

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

(goes in first frame)

```auto
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();

```
