本文介绍了Flex:PopUpManager给出“...空对象引用”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主要的应用程序调用几个ViewStack状态,每个状态都有弹出窗口。如果我不打开任何弹出窗口,我可以在状态之间移动罚款。如果我打开一个弹出窗口然后尝试改变状态使用 currentState = ... 我得到错误:

  TypeError:错误#1009:无法访问空对象引用的属性或方法。 
在spark.components :: Scroller / focusInHandler()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Scroller.as: 2139]
在flash.display :: Stage / set focus()
在mx.core :: UIComponent / setFocus()[E:\dev\4.y\frameworks\projects \framework\src\mx\core\UIComponent.as:9905]
...

我看到其他人有同样的问题,例如这里:
$ b $ p 1031531rel =nofollow> http://forums.adobe.com/thread/1031531















但我还没有想出如何实施推荐的解决方案。这听起来像我应该只包括:

  import mx.managers.PopUpManager; PopUpManager中; 

在我的主应用程序中,它应该可以正常工作,但是对我来说不起作用。

我的应用程序的每个视图状态都在一个不同的文件中,每个文件都使用< views:View> 来定义。另外,所有弹出窗口都是单独的文件,定义为< s:TitleWindow> 。每个文件都包含这一行:

  import mx.managers.PopUpManager; 

我想知道这是否意味着每个文件都使用不同的弹出式管理器(?),而只有一个应该用于整个应用程序(如何设置?)。

我用来调用弹出窗口的代码是:

  VAR _popupName:MyTitleWindowFileName = MyTitleWindowFileName(
PopUpManager.createPopUp(此,MyTitleWindowFileName,真));
_popupName.addEventListener(MyAppController.CLOSE_POPUP,onClosePopUp);
PopUpManager.centerPopUp(_popupName); //调用弹出窗口

注意,当主应用程序(定义为 < s:Application> )运行时,ViewStack状态还没有被加载(因为它们在第一次使用时被加载)。不知道这是否有任何原因/效果在这里。

我试图遵循Adobe的示例代码中传入和从Spark弹出窗口数据部的位置:





任何想法非常赞赏。

解决方案

看来这是我遇到的情况:



这是一个Adobe bug。 是:



通过更改Scroller在使用它之前对focusManager执行空指针检查, code>



这是上面第一个链接尝试做的事情。

另一个链接:


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/

http://bugs.adobe.com/jira/browse/SDK-32036?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

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 

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.

I've tried to follow Adobe's example code in the "Passing data to and from a Spark pop-up window" section here:

http://help.adobe.com/en_US/flex/using/WS6c678f7b363d5da52e8f1ca1124a0430dcf-8000.html#WS6c678f7b363d5da52e8f1ca1124a0430dcf-7ffe

Any ideas much appreciated.

解决方案

It appears this is the situation I'm experiencing:

Adobe Air: scroller throws error when changes focus between different applications

It's an Adobe bug. Solution from Adobe is:

This bug is easily fixed by changing Scroller to do a null pointer check on focusManager before using it.

which is what the first link above attempts to do.

Another link: http://forums.adobe.com/message/3812805

这篇关于Flex:PopUpManager给出“...空对象引用”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 17:11