2011-09-23 64 views
1

最近,我突然开始从Flex库中引发当前异常。我正在处理的文件(Login.mxml)在加载时突然开始抛出这个异常。从StaticPropertyWatcher.as抛出异常

TypeError: Error #1009: Cannot access a property or method of a null object reference. 
    at mx.binding::StaticPropertyWatcher/updateParent()[E:\dev\4.x\frameworks\projects\framework\src\mx\binding\StaticPropertyWatcher.as:150] 
    at _components_LoginWatcherSetupUtil/setup() 
    at components::Login()[C:\Users\username\Documents\MP_MAIN\src\components\Login.mxml:0] 
    <snip ...> 
    at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:700] 
    at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072] 

在调试器中运行它并没有给我行我的代码是错误的,但它确实给我StaticPropertyWatcher线。具体做法是:

override public function updateParent(parent:Object):void 
{ 
    // The assumption is that parent is of type, Class, and that 
    // the class has a static variable or property, 
    // staticEventDispatcher, of type IEventDispatcher. 
    parentObj = Class(parent); 

    if (parentObj["staticEventDispatcher"] != null) /* Exception thrown from here */ 
    { 
    ... 

调试器显示parentObj确实是零,解释该异常的直接原因,但我似乎无法确定更深的原因(即我做错了什么)。从_components_LoginWatcherSetupUtil类中调用updateParent方法,但调试器说没有代码,所以我写的内容和导致异常的内容之间的关键连接丢失了。

所以,基本上,我甚至不能调试这个。如何解决发生问题的任何想法?

+1

有时可以使调试运行过去的错误,如果你能做到这一点,并使用踏进按钮,它会带你回去到调用抛出错误的方法的那一行。 –

回答

0

经过费力地加回自上次提交到我的存储库以来所做的每一项更改,我追查了这个问题的罪魁祸首。基本上,有用于跟踪服务器的地址是这样几个静态变量:

public static var MAIN:String = "http://192.168.1.1/"; 
public static var MANAGE:String = MAIN + "Manage/"; 

的问题是,我使用非编译时常MAIN初始化MANAGE。将这些变量更改为const可以解决问题。

public static const MAIN:String = "http://192.168.1.1/"; 
public static const MANAGE:String = MAIN + "Manage/"; 

希望这将有助于其他人碰到这个问题来

0

您的错误报告为Login.mxml:0
当我将第0行看作错误时,它告诉我某种语法错误。打开字符串也许?
我会建议看看该文件,看看它是否设置正确。

发布完整的Login.mxml文件,让我们看看它。

+0

编译得很好,而Flash Builder中的语法突出显示器没有显示任何内容。我认为它的第0行的原因是在Login.mxml组件的初始化和设置过程中发生异常。 – deontologician

+0

当我告诉你问题不在Adobe库中时,请相信我。请发布Login.mxml –

+0

啊,我看到你明白了 –