Well... There is no way I could solve your problem with that much of information, but I could at least trim your code...
ActionScript Code:
// Key pressed while CAPTAIN is walking
// This Key Listener needs to be defined only once...
keyListener = new Object();
keyListener.onKeyDown = function()
{
if (Key.isDown(Key.LEFT))
{
if (_root.backGround._x < 20)
{
_root.backGround._x += 1;
// You will need to specify
// the path for the following...
move(-walkSpeed);
_xscale = -100;
distance = -4;
}
}
if (Key.isDown(Key.RIGHT))
{
if (_root.backGround._x > -20)
{
_root.backGround._x -= 1;
// You will need to specify
// the path for the following...
move(walkSpeed);
_xscale = 100;
distance = 4;
}
}
};
Key.addListener(keyListener);
function KeyPressHorizontalWalk()
{
/*
I have moved your codes in if block
because that's where the code belongs...
You do not need this KeyPressHorizontalWalk()
function actually since this is being
calculated with the keyListener...
// Next is the code to scroll the background.
// Code which makes Captain America Walk.
if (Key.isDown(Key.LEFT))
{
}
else if (Key.isDown(Key.RIGHT))
{
}
*/
}
// Keys pressed while CAPTAIN is jumping/falling
function KeyPressHorizontalJump()
{
/*
You don't need this function either...
I don't understand why you need to
repeat the same code over and over...
What is the difference between
KeyPressHorizontalWalk() function and
KeyPressHorizontalJump() function???
if (Key.isDown(Key.LEFT))
{
move(-jumpSpeed);
_xscale = -100;
distance = -4;
}
else if (Key.isDown(Key.RIGHT))
{
move(jumpSpeed);
_xscale = 100;
distance = 4;
}
*/
}
stop();
Check out the comments that I have made and answer those questions since you will need to clarify them for whoever helps you... I think you need to create a sample file and have it uploaded so that other people can take a look at it...
I am off to bed now, but I think somebody else will take a look at your question...
Good luck...