尝试在应用程序中居时,Pop会出错

时间:2011-09-22 06:47:37

标签: flex4 popup

Hello I am having this error when trying to center my popUp. If I remove the centerPopUp code line, the popUp appears but of course is not centered.

The Error is as such:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.managers::PopUpManagerImpl/centerPopUp()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:494]

My Code:

    var helpWindow:TitleWindow=
                    PopUpManager.createPopUp(this, screen_Name, true) as TitleWindow;
                    PopUpManager.centerPopUp(helpWindow);


Can someone address this issue?

1 个答案:

答案 0 :(得分:0)

如果你想稍后将panel / titleWindow置于中心位置,你应该将FlexGlobals.topLevelApplication作为参数传递给createpopup。

所以,这里将是

var helpWindow:TitleWindow=
                    PopUpManager.createPopUp(this,FlexGlobals.topLevelApplication , true) as TitleWindow;
                    PopUpManager.centerPopUp(helpWindow);

我相信这会奏效。