AS3类型错误:错误#1007:实例化尝试对非构造函数 [英] AS3 TypeError: Error #1007: Instantiation attempted on a non-constructor
本文介绍了AS3类型错误:错误#1007:实例化尝试对非构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关(失败很大程度上简化code)某种原因,我不能得到这个工作:
包com.domain {
公共类SomeClass的{
私人静止无功助手:助手=新助手();
}
}
一流的助手{
}
它编译,但抛出后的第一次访问 SomeClass的
:
类型错误:错误#1007:实例化尝试对非构造函数。
在com.domain :: SomeClass的$ cinit()
...
解决方案
+1达伦。另一种选择是将助手
类移动到文件的顶部
类助手{
}
包com.domain {
公共类SomeClass的{
私人静止无功助手:助手=新助手();
}
}
For some reason I can't get this to work (heavily simplified code that fails):
package com.domain {
public class SomeClass {
private static var helper:Helper = new Helper();
}
}
class Helper {
}
It compiles, but throws upon first access of SomeClass
:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at com.domain::SomeClass$cinit()
...
解决方案
+1 to Darren. Another option is to move the Helper
class to the top of the file
class Helper {
}
package com.domain {
public class SomeClass {
private static var helper:Helper = new Helper();
}
}
这篇关于AS3类型错误:错误#1007:实例化尝试对非构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文