2010-09-08 79 views

回答

15
var instance : MyClass = Type.createInstance(Type.resolveClass("path.to.MyClass"), []); 

几点注意事项:

  • resolveClass()取CLASSE的(包括封装)的完整路径需要
  • createInstance()取作为第二个参数被施加到构造值的数组。这些值必须是准确的数字,即使它们是可选的也必须通过(在这种情况下,空值是好的)。
+0

我在HaXe 3.0中看不到“Type.createInstance”,现在正在寻找替代品。 – FlavorScape 2013-12-04 23:26:50

+0

在这里:http://api.haxe.org/Type.html#createInstance – 2013-12-11 16:55:42

+0

呵呵是啊意外自动导入“haxe.macros.type”显然没有这种方法。 – FlavorScape 2013-12-11 22:09:56

相关问题