focusManager null Exception in Scroller

Currently working on an interesting “Top Secret” gap feature. One of the requirements we have for this feature is to be able to max and restore it. While trying to setup the max and restore  I ran into a null error in the class relating to the focusManger.

Attempted pop-up logic went something like this:

IVisualElementContainer(resizeComponent.parent).removeElement(resizeCo mponent);
FlexGlobals.topLevelApplication.systemManager.addChild(resizeComponent );

Which lead to an error in when you would attempt to focus in on the component post resize:

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

So the helpful Adobe forums came to my rescue without telling me to just read the documentation.

The Spark component I was attempting to popup did not implement the IFocusManagerContainer interface (hence the null..). In the end I went with SkinnableContainer as my wrapper.

Finally I should also have been using PopUpManager. So max’ing can now go something like this:


PopUpManager.addPopUp(this, DisplayObject(FlexGlobals.topLevelApplication), true);

Just don’t loose that reference to the original parent!


3 thoughts on “focusManager null Exception in Scroller

  1. Pingback: Implementing IFocusManagerContainer « Kevin Gaffney

  2. I had this occur as well. What solved it was implementing IFocusManagerContainer in my ItemRenderer, implements=”mx.managers.IFocusManagerContainer”.

    Then I add the following code to it:

    public function get defaultButton():IFlexDisplayObject {
    return null;

    public function set defaultButton(value:IFlexDisplayObject):void {


    override public function get systemManager():ISystemManager {
    return null;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s