Adobe Air: scroller gives an error when changing focus between different applications

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]
    at spark.components::RichEditableText/setFocus()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\RichEditableText.as:3126]
    at spark.components.supportClasses::SkinnableTextBase/setFocus()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableTextBase.as:1874]
    at mx.managers::FocusManager/activateWindowHandler()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\FocusManager.as:740]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:13152]
    at spark.components::WindowedApplication/nativeWindow_activateHandler()[E:\dev\4.y\frameworks\projects\airspark\src\spark\components\WindowedApplication.as:2739]

In my Adobe Air program, I got the above error whenever I use my application and switch focus between this application and other applications. (I tried several times, and this error is reproducible.)

What causes this problem and how to fix it?

EDIT: my program has a stack, and in one of the stacks a list. This error will occur above if there is at least one object in the list.

+3
source share
4 answers

SDK. Scroller, checkManager!= Null. -

package components
{
    import flash.events.FocusEvent;
    import spark.components.Scroller;
    public class MyScroller extends Scroller
    {
        public function MyScroller()
        {
            super();
        }

        override protected function focusInHandler(event:FocusEvent):void
        {
            if(focusManager != null) {
                super.focusInHandler(event);
            }
        }
    }
}

,

+2

, , , .

dataGrid.scroller.addEventListener(FocusEvent.FOCUS_IN, dataGridFocusInHandler, false, 1);

protected function dataGridFocusInHandler(event:FocusEvent):void {
    if(dataGrid.scroller.focusManager == null) {
        event.stopImmediatePropagation();
    }
}

,

Cheers Adz

+1

, , PopUpManager/PopUpAnchor focusManager, , , IFocusManagerContainer. .

+1

I had this problem, and it turned out that it was caused by some buttons that I had as rendering elements in my grid. These buttons change the view to another section and, apparently, retain focus after clicking, causing all kinds of problems. I set them focusEnabled = false and it solved the problem.

0
source

All Articles