Luar's Flash Playground:Delegate Class補充
新聞(100)
觀點或評論(93)
Flash書(63)
教程(65)
Design Patterns(3)
FlashCom筆記(45)
Flash Remoting筆記(27)
Flex筆記(11)
Flash Lite筆記(14)
PHP資訊(22)
Ajax筆記(9)
習作(47)
組件(15)
酷站(31)
學習資源(28)
書籍推介(15)
本站與我(90)
RSS瀏覽器
聯絡
熱愛鑽研
Ajax
ActionScript
Flash
Flash Lite
Flex
Flash Remoting
FlashCom
Director
Lingo
PHP
Multiplayer Game

搜尋
VCASMO
Delegate Class補充 (07-11-2004)

《AS2與RIA》書第5-14頁講解Delegate Class時,只交待註冊組件事件的觀察者做法:

cb.addEventListener("change", Delegate.create(this, onComboBoxChange));
但這做法,因為缺少了Reference,變成無法移除組件事件的觀察者,因此,如果日後需要移除,可以寫成:
var cbDelegate:Function = Delegate.create(this,onComboBoxChange);
cb.addEventListener("change", cbDelegate);
cb.removeEventListener("change", cbDelegate);
更進一步參考資料:

本文章由luar發表。
同組文章

Movable Type 3.15系統支持,Luar's Production版權所有。