2011-09-22 47 views
0

我有問題需要刪除我的應用程序的PopUp表單。實際上,我有一個帶有組件的標題窗口。在組件中,我有一個按鈕,點擊時應該刪除TitleWindow(PopUp)。我得到的錯誤:通過PopUpManager刪除TitleWindow時出錯

TypeError: Error #1009: Cannot access a property or method of a null object reference. 

我的標題窗口如下:

<?xml version="1.0" encoding="utf-8"?> 
<s: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" left="10" 
       width="1366" height="768"> 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 

    <fx:Script> 
     <![CDATA[ 
      import mx.managers.PopUpManager; 

    public function removeTitleWindow():void { 
       PopUpManager.removePopUp(this); 
      } 

     ]]> 
    </fx:Script> 

    <s:VGroup width="100%" height="100%" horizontalAlign="left"> 
     <comps:SearchEngine /> 
     <comps:SearchResults /> 
    </s:VGroup> 

</s:TitleWindow> 






My Component is as follows: 

<?xml version="1.0" encoding="utf-8"?> 
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx" width="400 " height="300"> 

<fx:Declarations> 

    </fx:Declarations> 

    <fx:Script> 
     <![CDATA[ 


     ]]> 
    </fx:Script> 


      <s:Button label="Cancel" click="parentApplication.parentApplication.removeTitleWindow()"/> 

    </s:VGroup> 

</s:Group> 

有人可以幫我在這? 感謝

回答

0

得到它配合:)

我嘗試使用parentApplication或者說flexGlobals.top ...它沒有工作。

因此我使用了parentDocument.methodName()。

這解決了這個問題。