You could try something like the following code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, downKey);
function downKey(event:KeyboardEvent)
{
if( event.keyCode == Keyboard.UP )
{
isUp=true;
character.gotoAndStop('up'); // up (animated?)
}
else if( event.keyCode == Keyboard.DOWN )
{
isUp=false;
character.gotoAndStop('down'); // down (animated?)
}
else if( event.keyCode == Keyboard.LEFT )
{
if( isUp )
character.gotoAndStop('left'); // (up)left
else
character.gotoAndStop('downleft'); // downleft
}
else if( event.keyCode == Keyboard.RIGHT )
{
if( isUp )
character.gotoAndStop('right'); // (up)right
else
character.gotoAndStop('downright'); // downright
}
}
stage.addEventListener(KeyboardEvent.KEY_UP, upKey);
function upKey(event:KeyboardEvent)
{
if( event.keyCode == Keyboard.RIGHT || event.keyCode == Keyboard.LEFT )
{
if( isUp )
character.gotoAndStop('up'); // up (still?)
else
character.gotoAndPlaygotoAndStop('down'); // down (still?)
}
}
I tried to do something as close as possible to your original code.
But it's yet a very simple solution that doesn't handle multi-key pressed at the same time etc... And obviously you should consider different keyframes for immobile and animated "up" and "down". I supposed that your bools were globals so I reduced it to one because it doesn't seems useful in this portion of code, but indeed you can re-introduce the other bools if needed elsewhere.