是否可以在 AS3 中创建“API”来添加影片剪辑/位图?我试过这样做:
public function addImage(name:String, x:int, y:int, type:String = "MovieClip", path:String = null) {
var mc:MovieClip;
if (type == "MovieClip") {
var $name = "as_" + name + "()"
mc = new $name;
trace(mc);
}
else if (type == "Bitmap") {
}
}
但它错误:
TypeError: Error #1007: Instantiation attempted on a non constructor
有这样做的正确方法吗?还是不能以这种方式将影片剪辑添加到舞台?