[MX] 2 keys

in actionscript, Is there a way i can make a coddition happen if 2 keys at once are presssed?

example:
if (Key.isDown(Key.SHIFT) && (Key.isDown(Key.LEFT) && _currentframe == 1)) {
gotoAndPlay(“running_left”);
} else if (Key.isDown(Key.RIGHT) && (Key.isDown(Key.RIGHT) && _currentframe == 1)) {
gotoAndPlay(“running_right”);
}

or can’t i do shift and left/right?

michelle

I had a go at what you were trying to achieve and came up with this code that seemed to work…

onClipEvent (enterFrame) {
if ((Key.isDown(Key.SHIFT)) and (Key.isDown (Key.LEFT))) {
this.gotoAndStop(“running_left”);
} else if ((Key.isDown(Key.SHIFT)) and (Key.isDown(Key.RIGHT))) {
this.gotoAndStop(“running_right”);
}
}

You put that code on the actaul moveclip that i assume you are trying to animate (-:

Another option by using the Key listener…
This won’t take more CPU power than onEnterFrame handler…

keyDetector = new Object();
keyDetector.onKeyDown = function()
{
	if ((Key.isDown(Key.SHIFT)) && (Key.isDown(Key.LEFT)))
	{
		yourMC.gotoAndStop("running_left");
		trace("running_left");
	}
	else if ((Key.isDown(Key.SHIFT)) && (Key.isDown(Key.RIGHT)))
	{
		yourMC.gotoAndStop("running_right");
		trace("running_right");
	}
};
Key.addListener(keyDetector);

Please use code formatting next time when you post the code… :wink: