var dx:int=-5; //it will roll from right to left var dr:int=2; //rotation speed back1.x=0; //touching the left edge and filling the stage back2.x=-back2.width; //off stage, touching left edge this.addEventListener(Event.ENTER_FRAME,roll); function roll(e:Event): void { back1.x=back1.x+dx; //move the two backgrounds in tandem back2.x=back2.x+dx; //if dx is positive, put piece on the left when it leaves on the right if(back1.x>stage.stageWidth) back1.x=-back1.width; if(back2.x>stage.stageWidth) back2.x=-back2.width; //if dx is negative, put piece on right when it leaves on the left if(back1.x<-back1.width) back1.x=stage.stageWidth; if(back2.x<-back2.width) back2.x=stage.stageWidth; car.wheel1.rotation=car.wheel1.rotation+dr; car.wheel2.rotation=car.wheel2.rotation+dr; } //roll