flex removeEventListener MDIWINDOW 移除 timer

來源:互聯網
上載者:User

項目用了 MDIWindow

 

其中一個MDIWindow開啟的時候會建立一個timer 定時去請求資料

 

問題是:當我把這個window關掉的時候 這個timer 還是會一直執行,而且再開一個這個window又會再新增一個timer 如此下去 會有很多timer

 

我還以為window關閉的時候會自動銷毀,但是貌似網上說FLEX的GC有很多bug 而且很多個物件不會被及時的GC

 

首先想到的是在mdiwindow關閉的時候添加監聽移除timer的事件

 

win.addEventListener(MDIWindowEvent.CLOSE,function(e:Event):void{tm.timeEnd();});

 

建立單例的方式也不行 因為關掉之後至少還有一個timer在運行..

private static var _instance:AppContext; public static function getInstance():AppContext {          if(_instance == null) {              _instance = new AppContext();          }          return _instance;      }

 最後決定 單例+mdiwindow關閉的時候添加監聽移除timer的事件

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.