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.
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();