# How to play sound file from object clicked?

**URL:** <https://forum.kirupa.com/t/how-to-play-sound-file-from-object-clicked/321217>\
**Category:** flash\
**Created:** [April 13, 2011, 3:27pm UTC](https://forum.kirupa.com/t/how-to-play-sound-file-from-object-clicked/321217 "2011-04-13T15:27:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manx\_Mariner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Manx\_Mariner](https://forum.kirupa.com/u/Manx_Mariner)\
**Post date:** [April 13, 2011, 3:27pm UTC](https://forum.kirupa.com/t/how-to-play-sound-file-from-object-clicked/321217/1 "2011-04-13T15:27:11Z")

</div>

What I have are several items on a stage and when they are clicked I want to capture their names so I can use it to play a sound file that relates with the object clicked. For example: say I have a square, rectangle, and a square on the stage and when the user clicks on “triangle” it would play the sound “triangle\_snd”. This is what I have so far and the error I am getting from it.

Triangle instance name: triangle\_1  
Triangle class name: Triangle\_1  
Triangle sound file class name: Triangle\_1\_Snd

TypeError: Error #1007: Instantiation attempted on a non-constructor.

```php

        function objectClick(e:MouseEvent):void {
			trace("this MC was clicked: " + e.target ); //returns "Triangle_1"
			sndFile = (e.target + "_Snd");
			var myLetterSound:Sound = new sndFile(); // if I put "triangle_1_snd()" in place of "sndFile()" here it works but of course all the other objects have the same sound file.
			myLetterSound.play();

```
