AS3 -TypeError#1009 - 任何简单的方法来找出其中* *对象的引用为空?
我们都得到类型错误#1009无法访问空对象引用的属性或方法现在,然后 - 没什么大不了的,但有时令人沮丧的调试。
We all get "TypeError #1009 Cannot access a property or method of a null object reference" now and then - no big deal, but sometimes frustrating to debug.
闪存让你的调用堆栈(这是一个开始),但保留这些给你找出其中的空对象是 - 是否有可能发现的到底是哪个的参考抛错误?
Flash gives you the call stack (which is a start), but leaves it up to you to figure out where the null object is - is it possible to find out exactly which reference is throwing the error?
由于以下(容易出错)功能:
Given the following (error prone) function:
function nullObjectReferenceError():void
{
var obj:Object;
var prop:* = obj.nonExistentProperty;
}
而不是仅仅从类型错误调用堆栈,我想追查是这样的:的在 obj.nonExistentProperty 的无法访问空对象引用的属性或方法STRONG>? - 这甚至可能
Rather than just the call stack from the TypeError, I'd like to trace something like: "Cannot access a property or method of a null object reference at obj.nonExistentProperty" - Is this even possible?
如果您选中允许调试下发布设置在Flash IDE,它可以让你在你的code行号导致错误。
If you check Permit Debugging under Publish Settings in the Flash IDE, it gives you the line number in your code causing the error.