If there are any English readers, feel free to contact me via LinkedIn.

注意:本文可能存在更多解释,没有时间一一考证了。

今天,遇到一个棘手的错误:

TypeError: Error #1010: A term is undefined and has no properties.

这个错误令人有些无所适从,毕竟你根本不知道这个“term”究竟是哪个。

不过,一翻折腾后,我终于找到了元凶:原来,是在在引用一个已定义对象的未定义属性时,将这个属性再次作为对象来引用时出错。

有点绕口,不过看代码就明白了:

简单的例子我就不做变量类型声明了,直接写在AS3的MainTimeline上:

代码片段一:

var o = {};
o.a  = 5;
trace(o.a); // 没问题
trace(o.b); // 引用未定义对象,输出undefined

代码片段二:

var o = {};
o.a  = 5;
trace(o.a); // 没问题
trace(o.b.c); // 引用已定义对象(o)的未定义属性(b)作为对象的某一属性(c)

这时候不再简单地输出undefined,而是输出开头的错误。

Still looking for something?

: http://as3blog.com/as3/type-error-1010-a-term-is-undefined-and-has-no-properties/

Post a comment now » Sorry, the comments are closed.

No comments yet.

Sorry, the comment form is closed at this time.