开发者

instantiate sound clips dynamically in as3

开发者 https://www.devze.com 2022-12-31 11:08 出处:网络
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 {

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号