12 Replies Latest reply on Aug 10, 2016 7:56 AM by leono18688451

    FocusManager generates error

    JockMahon Level 1

      I get this error when trying to close a title window.

       

      TypeError: Error #1009: Cannot access a property or method of a null  object reference.
          at  mx.managers::FocusManager/childHideHandler()[E:\dev\4.0.0\frameworks\projects\framework\s rc\mx\managers\FocusManager.as:1744]
           at flash.events::EventDispatcher/dispatchEventFunction()
          at  flash.events::EventDispatcher/dispatchEvent()
          at  mx.core::UIComponent/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\co re\UIComponent.as:12269]
           at  mx.core::UIComponent/setVisible()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\ UIComponent.as:3038]
           at mx.core::UIComponent/set  visible()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:2997]
           at  mx.controls::Button/http://www.adobe.com/2006/flex/mx/internal::viewSkinForPhase()[E:\dev\4.0.0\frameworks\pro jects\framework\src\mx\controls\Button.as:1953]
           at  mx.controls::PopUpButton/http://www.adobe.com/2006/flex/mx/internal::viewSkin()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\controls\PopUpButton.as:712]
           at  mx.controls::Button/updateDisplayList()[E:\dev\4.0.0\frameworks\projects\framework\src\mx \controls\Button.as:1754]
           at  mx.core::UIComponent/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framework\src \mx\core\UIComponent.as:8531]
           at  mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:663]
           at  mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:736]
           at  mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]

       

      The line this is breaking on is

       

      DisplayObject(form).stage.focus = null;

       

      in the FocusManager, the stage is null

       

       

      the window is opened by the following

       

                      window= PopUpManager.createPopUp(this,ProductSearch,true) as ProductSearch;
                      window.addEventListener("loaded" , onWindowLoad );
                      window.addEventListener("close"  , closeWindow );
                      window.title = "Add Product - [ESC to close]"
                      window.closeButton.visible = false;

       

                      window.width = stage.width * 0.75;
                      window.height = stage.height * 0.65;
                         
                      var pt:Point = new Point(0, 0);
                      pt = stage.localToGlobal(pt);
                      pt = window.globalToLocal(pt);
                      window.move(Math.round((stage.width - window.width) / 2) + pt.x, Math.round((stage.height - window.height) / 2) + pt.y);                   
                     
                      CursorManager.setBusyCursor();

       

       

      and cloesed by

       

      PopUpManager.removePopUp(window);

       

       

      it is on the remove pop up call that it errors, if i comment it out then the window doesn't close and i don't get an error

       

      Help please

       

      ps i have other title window that close using this method just fine