In the Scroller.as class line 2139 I'm getting the following 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()
From Scroller.as
/**
* @private
* Listens for any focusIn events from descendants
*/
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;
}
}
Since this is framework code what option do I have to prevent it?
Context
I have created a pop up TitleWindow, added a Module in it and displayed it. The Module has a few States, in each State is a Group, one Group has a List, that List has an ItemRenderer, that ItemRenderer has a Checkbox.
The Module also has a Menu. When the Menu is opened the menu pop up lists the states the Module has available. When an item is selected from the menu pop up I change to another state.
When the state is changed and the last item is the checkbox then the error is generated. At least that's what I think is happening. I deduced this because in the Scroller class the handler is handling an event. On that event is the current target. That current target is the checkbox.
Update - Steps to reproduce
// inside the Application.mxml
// define variables
public var popup:Group;
public var titleWindow:TitleWindow;
// shows pop up
public function showInspector():void {
// inside show inspector method
// create new inspector container
popup = new InspectorContainer(); // a group implements="mx.managers.IFocusManagerContainer"
titleWindow = new TitleWindow();
titleWindow.addElement(popup);
// display pop up title window
PopUpManager.addPopUp(titleWindow, this, false);
}
<fx:Declarations>
<modules:InspectorContainer/>
</fx:Declarations>
Show pop up. The pop up is a Title Window with InspectorContainer (a group) as the first element.
In pop up change from home state (default state) to online state (this happens when the user clicks a button). The online state has a List. The List has an itemrenderer. The itemrenderer has a checkbox. Select the checkbox. So far so good.
The pop up (InspectorContainer) has a mx:MenuBar instance. When you click on an item in the menubar the menubar displays a menu items.
Click an item in the menu list. The itemClick menuHandler is called. In this function the pop up changes state.
This is when the error occurs.