# Play sond once when attacking

**URL:** <https://forum.kirupa.com/t/play-sond-once-when-attacking/309231>\
**Category:** programming\
**Created:** [May 10, 2010, 4:09pm UTC](https://forum.kirupa.com/t/play-sond-once-when-attacking/309231 "2010-05-10T16:09:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yrvader](https://avatars.discourse-cdn.com/v4/letter/y/a3d4f5/32.png) [@Yrvader](https://forum.kirupa.com/u/Yrvader)\
**Post date:** [May 10, 2010, 4:09pm UTC](https://forum.kirupa.com/t/play-sond-once-when-attacking/309231/1 "2010-05-10T16:09:48Z")

</div>

Hello!

I am trying to make a platform game in flash and want the character to play a sound everytime i hit the attackbutton, but only once.

I´ve tried everything i can come up with, but the sound just keeps looping over and over.  
What to do?

Code for the attack:

if (Key.isDown(\_root.ATTACKKEY)) {  
//if the player is pushing the attack key

```
    if (_root.mcPLAYER.GROUNDED == true && _root.ATTACK == 1) {
        //if the player is grounded
        if (_root.mcPLAYER.DIRECTION == "R") {
            //if the player is facing right
            _root.mcPLAYER.gotoAndPlay(13);
            //show the player attack facing right frame
        } else {
            //if the player is facing left
            _root.mcPLAYER.gotoAndPlay(14);
            //show the player attack facing left frame
        }

```

and in the mcPLAYER frame 13 and 14, I have placed the sound in the timeline and at the end I also put stop();

However… it keeps repeating…

Can anyone help me? Thanks for your time 🙂
