views:

26

answers:

1

How can i call and instantiate soundclips in my library dynamically

here is the code i have so far

function soundbutton_Handler (e:MouseEvent):void {
trace(e.target.name);
var mySound:Sound = new e.target();

mySound.play();
}

and the error i get is : Error #1007: Instantiation attempted on a non-constructor. at quiz_fla::MainTimeline/soundbutton_Handler()

A: 

I got it, for future reference if any one needs help i 'm posting the solution here

var classRef:Class = getDefinitionByName(e.target.name) as Class;
var mysound:Sound = new classRef();
mysound.play();