读书人

Flex 中很幽魂的一个bug

发布时间: 2012-11-04 10:42:42 作者: rapoo

Flex 中很幽灵的一个bug

如题:

?

偶尔会出现如下错误,在debug的时候:

?

TypeError: Error #1009: Cannot access a property or method of a null object reference

at spark.components::Scroller/focusInHandler()[....\sdks\4.5.1\frameworks\projects\spark\src\spark\components\Scroller.as:1273]

?

跟进代码中去看1273 行如下:

?

override protected function focusInHandler(event:FocusEvent):void
??? {
??????? super.focusInHandler(event);
???????
??????? // When we gain focus, make sure the focused element is visible
??????? if (viewport && ensureElementIsVisibleForSoftKeyboard)
??????? {
??????????? var elt:IVisualElement = focusManager.getFocus() as IVisualElement;
??????????? lastFocusedElement = elt;
??????? }
??? }

?

我的项目中有四个popup,至于到底是不是popup弹出窗口引起的,还不是很清楚、、、

先按照他提供的方法fix掉了:

?

解决办法如下:

?

The problem is that your popup doesn't implement the IFocusManagerContainer interface.

Implementing IFocusManagerContainer allows the system to assign a FocusManager to the popup, and this error goes away.

?

于是我在popup弹出窗口的(也就是TitleWindow)中加了个属性:

implements="mx.managers.IFocusManagerContainer"

?

至于好没有好,还得验证过一段时间。。。O(∩_∩)O~

读书人网 >flex

热点推荐