Flex:PopUpManager 给出“...空对象引用";错误 [英] Flex: PopUpManager giving "...null object reference" error
问题描述
我有一个主应用程序调用多个 ViewStack 状态,每个状态都有弹出窗口.如果我不打开任何弹出窗口,我可以在状态之间正常移动.如果我打开一个弹出窗口,然后尝试使用 currentState=...
更改状态,我会收到错误消息:
I have a main application calling several ViewStack states, each with popup windows. If I don't open any popup windows, I can move between states fine. If I open a popup window then try to change the state using currentState=...
I get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at spark.components::Scroller/focusInHandler()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Scroller.as:2139]
at flash.display::Stage/set focus()
at mx.core::UIComponent/setFocus() [E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:9905]
...
我看到其他人也有同样的问题,例如这里:
I see others having the same problem, for example here:
http://forums.adobe.com/thread/1031531
http://forums.adobe.com/message/2767130
http://forums.adobe.com/message/3448443
http://forums.adobe.com/thread/655749?tstart=-1
http://forums.adobe.com/thread/801149
http://flex4examples.wordpress.com/2011/05/05/skinnabletextbase-focusmanager-runtime-error-popup/
但我还没有想出如何实施推荐的解决方案.听起来我应该包括:
But I haven't figured out how to implement the recommended solution. It sounds like I should just include:
import mx.managers.PopUpManager; PopUpManager;
在我的主应用程序中,它应该可以工作,但对我不起作用.
inside my main application and it should work, but it doesn't work for me.
我的应用程序在不同的文件中有每个视图状态,每个视图状态都使用
定义.此外,所有弹出窗口都是定义为
的单独文件.每个文件都包含这一行:
My application has each view state in a different file, each defined using <views:View>
. Also, all of the popups are separate files defined as <s:TitleWindow>
. Each file includes this line:
import mx.managers.PopUpManager;
我想知道这是否意味着每个文件都使用不同的弹出管理器(?),当它是一个单独的并且整个应用程序应该只使用一个(如何设置?).
I wonder if this means each file is using a different popup manager(?), when it's a singleton and only one should be used for the whole app (how to set that up?).
我用来调用弹出窗口的代码是:
The code I use to call a popup is:
var _popupName:MyTitleWindowFileName = MyTitleWindowFileName(
PopUpManager.createPopUp(this, MyTitleWindowFileName, true));
_popupName.addEventListener(MyAppController.CLOSE_POPUP,onClosePopUp);
PopUpManager.centerPopUp(_popupName); // call popup
请注意,当主应用程序(定义为
的应用程序)运行时,ViewStack 状态尚未加载(因为它们在第一次使用时已加载)).不确定这是否有任何因果关系.
Note that when the main application (the one defined as <s:Application>
) runs, the ViewStack states have not been loaded yet (since they get loaded when they are used the first time). Not sure if that has any cause/effect here.
我尝试在此处遵循将数据传入和传出 Spark 弹出窗口"部分中的 Adobe 示例代码:
I've tried to follow Adobe's example code in the "Passing data to and from a Spark pop-up window" section here:
非常感谢任何想法.
推荐答案
看来这就是我遇到的情况:
It appears this is the situation I'm experiencing:
Adobe Air:滚动条在以下情况下引发错误在不同的应用程序之间改变焦点
这是一个 Adobe 错误.解决方案来自Adobe 是:
It's an Adobe bug. Solution from Adobe is:
这个bug很容易通过改变Scroller在使用之前对focusManager做空指针检查来修复.
这是上面第一个链接尝试做的.
which is what the first link above attempts to do.
另一个链接:http://forums.adobe.com/message/3812805
这篇关于Flex:PopUpManager 给出“...空对象引用";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!