# Attaching sound when enemy dies?

**URL:** <https://forum.kirupa.com/t/attaching-sound-when-enemy-dies/264543>\
**Category:** programming\
**Created:** [June 27, 2008, 12:15am UTC](https://forum.kirupa.com/t/attaching-sound-when-enemy-dies/264543 "2008-06-27T00:15:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amymation](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Amymation](https://forum.kirupa.com/u/Amymation)\
**Post date:** [June 27, 2008, 12:15am UTC](https://forum.kirupa.com/t/attaching-sound-when-enemy-dies/264543/1 "2008-06-27T00:15:31Z")

</div>

Hi guys.  
I’ve been making this pretty cool game and I’ve got all coding right and all but what I want to do is when the enemy dies (when hittest with char) I want it to play the sound “ding”. I’ve tried so many things such as attachAudio attachSound etc…  
Could someone please tell me exactly what I need to type. The audio name in the library is: ding.

Please reply a.s.a.p!

---

<div class="post-metadata">

**Author:** ![Iamthejuggler](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@Iamthejuggler](https://forum.kirupa.com/u/Iamthejuggler)\
**Post date:** [June 27, 2008, 5:55pm UTC](https://forum.kirupa.com/t/attaching-sound-when-enemy-dies/264543/2 "2008-06-27T17:55:11Z")

</div>

is this in as2 or as3?

Assuming it’s as3 at the start of the flash do:

var soundURL:URLRequest = new URLRequest(“string to the sound filename”);  
var deathSound:Sound = new Sound();

and then in the death function do:

deathSound.play();
