# Key Crashes: Problem with animations

**URL:** <https://forum.kirupa.com/t/key-crashes-problem-with-animations/138788>\
**Category:** Uncategorized\
**Created:** [February 25, 2005, 10:40am UTC](https://forum.kirupa.com/t/key-crashes-problem-with-animations/138788 "2005-02-25T10:40:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grake](https://avatars.discourse-cdn.com/v4/letter/g/aca169/32.png) [@Grake](https://forum.kirupa.com/u/Grake)\
**Post date:** [February 25, 2005, 10:40am UTC](https://forum.kirupa.com/t/key-crashes-problem-with-animations/138788/1 "2005-02-25T10:40:50Z")

</div>

Erm lately I’m working on a game, and i encountered a problem . My main character has an idling animation and an attacking animation. I am suppose to slash my enemy **once only** and immediately shift back to my idling animation. But my movement controls are something like this:

if(Key.isDown(Key.Left))  
{  
this.gotoAndStop(“MoveLeft”);  
}  
else if(Key.isDown(Key.Right))  
{  
this.gotoAndStop(“MoveRight”);  
}  
else if(Key.isDown(Key.Space))  
{  
this.gotoAndStop(“Attack”);  
}  
else  
{  
this.gotoAndStop(“Idle”);  
}

//------------------------------

But if I press down the spacebar it will continue to attack non-stop, which i didn’t want it to, I only want it to attack once. If I change to onKeyUp for the attack button. My main character will crashes as it can’t decide whether to play the idle animations or attack animations. My main character is a movieClip and all the codes are inside it. Please help me… thanks…
