作者ckf (聽某嘴大富貴)
看板Flash
標題Re: [問題] 動態建立物件 如何替它建立事件呢?
時間Tue Apr 21 16:54:18 2009
: tempBall.addEventListener(MouseEvent.MOUSE_DOWN,abc);
: tempBall.addEventListener(MouseEvent.MOUSE_UP,abcD);
: function abc(e:MouseEvent):void {
: tempBall.startDrag()
: }
: function abcD(e:MouseEvent):void {
: tempBall.stopDrag()
: }
借標題
如果物件是自行建立的
沒有addEventListenr可以使用
要如何將event加入該自訂元件?!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.251.61.85
推 pm2001:那你的物件應該繼承有該事件的元件 04/21 16:59
推 cjcat2266:要使用MouseEvent,一定要繼承自InteractiveObject 04/21 23:09
→ cjcat2266:否則你要自己設計你的EventDispatcher subclass來自行 04/21 23:10
→ cjcat2266:丟出MouseEvent (透過EventDispatcher.dispatchEvent()) 04/21 23:10
→ ckf:thanks!! 04/24 17:00