AS3 -TypeError#1009 - 任何简单的方法来找出*哪个*对象引用为空? [英] AS3 -TypeError #1009 - any easy way to find out *which* object reference is null?

查看:114
本文介绍了AS3 -TypeError#1009 - 任何简单的方法来找出*哪个*对象引用为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都得到TypeError#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给你调用堆栈(这是一个开始),但是留给你来确定null对象在哪里 - 是否可以找出正是哪个引用引发错误?

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;
    }

而不仅仅是TypeError的调用堆栈,我想跟踪类似于:无法访问 obj.nonExistentProperty 中的空对象引用的属性或方法 - 这是否可以?

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中的发布设置下检查许可证调试,它将为您的代码中的行号引起错误。

If you check Permit Debugging under Publish Settings in the Flash IDE, it gives you the line number in your code causing the error.

这篇关于AS3 -TypeError#1009 - 任何简单的方法来找出*哪个*对象引用为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆