var dx:int=4; //speed along x axis var dr:int=2; //rotation speed this.addEventListener(Event.ENTER_FRAME,moveCar); function moveCar(e:Event): void { car.x=car.x+dx; if(car.x<=0 || car.x>stage.stageWidth-car.width) { dx=dx*-1; //change direction of car dr=dr*-1; //change direction of rotation } //hit the edge car.wheel1.rotation=car.wheel1.rotation+dr; car.wheel2.rotation=car.wheel2.rotation+dr; } //move car