开发者

Exception being thrown from StaticPropertyWatcher.as

Recently, I suddenly began getting the current exception being thrown from a Flex library. The file I was working on (Login.mxml) suddenly began throwing up this exception while loading.

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/doPhasedInst开发者_如何学Goantiation()[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]

Running it in the debugger doesn't give me a line of my code that is in error, but it does give me a line in StaticPropertyWatcher. Specifically:

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 */
    {
    ...

The debugger shows the parentObj is indeed null, explaining the immediate reason for the exception, but I can't seem to determine the deeper cause (i.e. what I did wrong). The updateParent method is being called from the _components_LoginWatcherSetupUtil class, but the debugger says there is no code for that, so the crucial connection between what I wrote and what caused the exception is missing.

So, basically, I can't even debug this. Any ideas for what to do to shed light on what's going wrong?


Your error is being reported as Login.mxml:0
When I see line 0 as the error it tells me that there is a syntax error of some sort. Open string maybe?
I would suggest looking at the file and see if it is set up properly.

Post the full Login.mxml file and let us look at it.


After laboriously adding back every change I made since last committing to my repository, I tracked down the culprit to this problem. Basically, there were several static variables used to keep track of server addresses like this:

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

The issue was that I used a non-compile-time constant MAIN to initialize MANAGE. Changing these variables to const fixed the problem.

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

Hopefully this will help anyone else coming across this problem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜