# Flipping objects vertically

**URL:** <https://forum.kirupa.com/t/flipping-objects-vertically/184537>\
**Category:** flash\
**Created:** [April 5, 2006, 7:48pm UTC](https://forum.kirupa.com/t/flipping-objects-vertically/184537 "2006-04-05T19:48:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![woad](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@woad](https://forum.kirupa.com/u/woad)\
**Post date:** [April 5, 2006, 7:48pm UTC](https://forum.kirupa.com/t/flipping-objects-vertically/184537/1 "2006-04-05T19:48:37Z")

</div>

In my intializeChar function i’ve got it so that when you move left it turns your char left by doing \_root.grid.char.\_xscale \*= -1;

But that makes it so that every frame that your going left it will switch from looking left to looking right. What I want is to have the char face left while moving left and afterwards keep it looking left. And when going right it’s the opposite, how do I do that?

function initializeChar() {  
game.speed = 3;  
game.path.char.swapDepths(10000);  
game.char = {startx:1, starty:1, clip:game.path.char};  
var x = (game.char.startx-1)\*game.spacing+game.spacing/2;  
var y = (game.char.starty-1)\*game.spacing+game.spacing/2;  
game.char.clip.\_x = x;  
game.char.clip.\_y = y;  
game.char.x = x;  
game.char.y = y;  
game.char.radius = game.char.clip._width/2;  
}  
function moveChar(dir) {  
ob = game.char;  
if (dir == “right”) {  
var tempx = ob.x+ob.radius+game.speed;  
var tempy = ob.y;  
var cellx = Math.ceil(tempx/game.spacing);  
var celly = Math.ceil(tempy/game.spacing);  
var tempCell = game[“cell”+cellx+"_"+celly];  
if (tempCell.type != 1) {  
return;  
} else {  
\_root.grid.char.gotoAndPlay(2);  
ob.x += game.speed;  
ob.clip._x = ob.x;  
}  
} else if (dir == “left”) {  
var tempx = ob.x-ob.radius-game.speed;  
var tempy = ob.y;  
var cellx = Math.ceil(tempx/game.spacing);  
var celly = Math.ceil(tempy/game.spacing);  
var tempCell = game[“cell”+cellx+"_"+celly];  
if (tempCell.type != 1) {  
return;  
} else {  
\_root.grid.char.gotoAndPlay(2);  
\_root.grid.char.\_xscale \*= -1;  
ob.x -= game.speed;  
ob.clip._x = ob.x;  
}  
} else if (dir == “up”) {  
var tempx = ob.x;  
var tempy = ob.y-ob.radius-game.speed;  
var cellx = Math.ceil(tempx/game.spacing);  
var celly = Math.ceil(tempy/game.spacing);  
var tempCell = game[“cell”+cellx+"_"+celly];  
if (tempCell.type != 1) {  
return;  
} else {  
\_root.grid.char.gotoAndPlay(2);  
ob.y -= game.speed;  
ob.clip._y = ob.y;  
}  
} else if (dir == “down”) {  
var tempx = ob.x;  
var tempy = ob.y+ob.radius+game.speed;  
var cellx = Math.ceil(tempx/game.spacing);  
var celly = Math.ceil(tempy/game.spacing);  
var tempCell = game[“cell”+cellx+"_"+celly];  
if (tempCell.type != 1) {  
return;  
} else {  
\_root.grid.char.gotoAndPlay(2);  
ob.y += game.speed;  
ob.clip.\_y = ob.y;  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [April 5, 2006, 9:47pm UTC](https://forum.kirupa.com/t/flipping-objects-vertically/184537/2 "2006-04-05T21:47:30Z")

</div>

For starters x is horizontal. When moving left, set the movie clips \_xscale to -100 and when it’s moving right, to 100.
