# Scripting a fighting game help

**URL:** https://forum.kirupa.com/t/scripting-a-fighting-game-help/185039
**Category:** Uncategorized
**Created:** [April 10, 2006, 2:16pm UTC](https://forum.kirupa.com/t/scripting-a-fighting-game-help/185039 "2006-04-10T14:16:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mcarr1973](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@mcarr1973](https://forum.kirupa.com/u/mcarr1973)
#### Post date: [April 10, 2006, 2:16pm UTC](https://forum.kirupa.com/t/scripting-a-fighting-game-help/185039/1 "2006-04-10T14:16:39Z")

</div>

Hello all that reads,

I have my charcter(boxer) named my\_mc on the main timeline if you double click inside this movieclip you see my boxer has a punch labeled frame, kick labled frame and a knee labled frame. above the labels I tried putting actions to return my boxer to his original state of standing but it dosent work??? this is my code in frame 1 on the main timeline:

// stop the mc  
my\_mc.stop();  
// when you press a key  
my\_mc.onKeyDown = function()  
{  
// if it’s the A key  
if (Key.getCode() == 65) {  
// send the movie clip’s playhead to frame labeled kick  
this.gotoAndStop(“punch”);

}  
// if it’s the S key  
else if (Key.getCode() == 83)  
{  
// send the movie clip’s playhead to frame labeled punch  
this.gotoAndStop(“kick”);  
}  
// and so on

// if it’s the D key  
if (Key.getCode() == 68 {  
// send the movie clip’s playhead to frame labeled kick  
this.gotoAndStop(“knee”);  
}  
};  
// add the listener to the movie clip  
Key.addListener(my\_mc);

I have tried putting this.gotoAndPlay(“punch”); instaed of this.gotoAndStop but then it will just play through all of his motions.

My question is how do I do it so that when I push “a” for punch the boxer punches and then returns his punch instead of being stuck whith his arm out until I hit the next button?

Hopefully Someone can help  
michael

P.S. if anyone has a street fighter game or something like it could you send me the fla.file as a learning tool 🙂
