Right basically I have a character and a background. The background scrolls as you press left or right on keyboard to create the illusion of movement.
I want the character to flip when you change from holding down left to right and vice versa, but when I do the following code it doubles the size of the character once and then it stays. It flips fine but in the transformed fat size. Any ideas?
Here’s the code:
var mySpeed:Number = 10;
function keyIsDown(evt:KeyboardEvent):void{
if(evt.keyCode==Keyboard.RIGHT){
walkingPlane_mc.x+=mySpeed;
greyCharacter_mc.scaleX=-1;
}
if(evt.keyCode==Keyboard.LEFT){
walkingPlane_mc.x-=mySpeed;
greyCharacter_mc.scaleX=+1;
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyIsDown);