Jumping that jumps to the side ur sprite was facing

hello i am semi- new to flash and i am creating a platform game and i am using this script on my main sprite for direction.

if (Key.isDown(Key.RIGHT)) {
_root.mainsprite.gotoAndstop(2);
}
if (Key.isDown(Key.LEFT)) {
_root.mainsprite.gotoAndstop(3);
}
if (Key.isDown(Key.UP)) {
_root.mainsprite.gotoAndstop(4);
}
}

in the MC “mainsprite” -FRAME 1 - sprite facing right still
FRAME 2 - sprite walking right
FRAME 3 - sprite walking left
FRAME 4 - sprite jumping right

As u can see, when my man jumps the sprite faces the rightside even when my sprite is jumping to the left.

I would like something like this:

http://www.gotoandplay.it/_articles/2003/12/scrolling_upd.php

And i have downloaded the source file… i try not to let others do my work but i tryed extracting parts from it that would help me but nothing worked.

Thanks in advance

-Mike