我是 AS3 的新手。我的 fla 中有 15 个声音;我将它们导入库并导出名称为 s1, s2, s3, ... s15
我创建了一个接收数字然后播放声音的函数。
在 AS2 中,我可以像 eval("s"+ n)
一样使用 eval
,但在 AS3 中我不能!
我的 AS3 代码是:
function PlaySound(Num:Number=NaN) {
var mySound:Sound = new ["s"+Num]();
mySound.play();
}
显然我遇到了一个错误!
有人可以帮助我吗?
最好的,弗拉维奥
最佳答案
等效的 AS3 代码为:
var soundClass:Class = getDefinitionByName("s" + Num) as Class;
var mySound:Sound = new soundClass();
关于Flash AS3 求值(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7047942/