var dir = 0; this.onEnterFrame = function() { if(dir == 0){ if (this.bar_mc._x > -780) { this.bar_mc._x -= 15; } else { dir = 1; } } if(dir == 1){ if (this.bar_mc._x < 0) { this.bar_mc._x += 15; } else { dir = 0; } } };