3 Replies Latest reply on Apr 5, 2010 5:58 PM by Anderw jason

    cannot remove the titlewindow

    Anderw jason

      there are two titlewindows:one is the child of another. when "PopUpManager.removePopUp" is used to remove the child,there will be an error:cannot use the empty object..................

      what puzzle me is that the codes run in flex 4 beta2 well,but in flex 4 the error coming.

      my codes:

      main:

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">

      <fx:Script>
        <![CDATA[
         import mx.managers.PopUpManager;
         private var pop:popups;
         protected function init():void
         {
          pop=new popups();
         
         }
         protected function click_clickHandler(event:MouseEvent):void
         {
          PopUpManager.addPopUp(pop,this,true);
          PopUpManager.centerPopUp(pop);
         }
         protected function clicks(event:Event):void
         {   
         }
        ]]>
      </fx:Script>

      <fx:Declarations>
        <mx:DateFormatter id="former" formatString="YYYY/MM/DD"/>
      </fx:Declarations>
      <s:TextInput id="input" x="70" y="49"/>
      <s:Button id="click" click="click_clickHandler(event)" label="Click" x="70" y="79"/>
      </s:Application>

      titlewindows:

      <mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute"
          creationComplete="init()" width="400" height="300">

      <fx:Script>
        <![CDATA[
         import mx.managers.PopUpManager;
         private var pops:datpopup;
        
         protected function init():void
         {
          pops=new datpopup();
          pops.addEventListener("asb",adds);
         }
         protected function intext_clickHandler(event:MouseEvent):void
         {
          PopUpManager.addPopUp(pops,this);
          PopUpManager.centerPopUp(pops);
         
         }
        
         protected function adds(event:Event):void
         {
          intext.text=fm.format(pops.dataup.selectedDate);
          PopUpManager.removePopUp(pops);//
            
         }
        ]]>
      </fx:Script>

      <fx:Declarations>
        <mx:DateFormatter id="fm" formatString="YYYY/MM/DD"/>
      </fx:Declarations>

      <s:TextInput id="intext" click="intext_clickHandler(event)" />
      </mx:TitleWindow>

       

      child window:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" close="close()" width="400" height="300">
      <fx:Declarations>
       
      </fx:Declarations>
      <fx:Script>
        <![CDATA[
         import mx.managers.PopUpManager;
         private function close():void
         {
          PopUpManager.removePopUp(this);
         }
         private function changes():void
         {
          this.dispatchEvent(new Event("asb"));
         }
        ]]>
      </fx:Script>
      <mx:DateChooser id="dataup"  change="changes()"/>
      </mx:TitleWindow>

        • 1. Re: cannot remove the titlewindow
          Anderw jason Level 1

          the error in fact is that :cannot use "PopUpManager.removePopUp" to remove titlewindow that includs DateChooser,while clicking the data .

          Any ideas?

          • 2. Re: cannot remove the titlewindow
            Flex harUI Adobe Employee

            What is the full text of the error with the stacktrace?

             

            You can try delaying closing of the popup using callLater.

            1 person found this helpful
            • 3. Re: cannot remove the titlewindow
              Anderw jason Level 1

              HI,Flex harUI

              The full text error:

              TypeError: Error #1009: Can not access null object reference of the property or method。
              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:12266]
              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::CalendarLayout/http://www.adobe.com/2006/flex/mx/internal::setSelectedMonthAndYear()[E:\dev\4.0.0\framewo rks\projects\framework\src\mx\controls\CalendarLayout.as:1584]
              at mx.controls::CalendarLayout/updateDisplayList()[E:\dev\4.0.0\frameworks\projects\framewor k\src\mx\controls\CalendarLayout.as:1307]
              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]
              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:12266]
              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::CalendarLayout/mouseUpHandler()[E:\dev\4.0.0\frameworks\projects\framework\s rc\mx\controls\CalendarLayout.as:2497]