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 i开发者_开发百科s : Error #1007: Instantiation attempted on a non-constructor. at quiz_fla::MainTimeline/soundbutton_Handler()
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();
精彩评论