[問題] addEventListener()

看板Flash作者 (做個盾牌眼球兵吧)時間17年前 (2008/06/12 17:03), 編輯推噓3(303)
留言6則, 4人參與, 最新討論串1/3 (看更多)
假如不同的物件間註冊同樣的function 例如 textfield1.addEventListener(MouseEvent.CLICK,hit); textfield2.addEventListener(MouseEvent.CLICK,hit); textfield3.addEventListener(MouseEvent.CLICK,hit); 我的hit function有辦法可以判斷出是哪一個textfield處發這個事件嗎?thx -- ╲﹋﹌/ ╰○∕ ╭U╮ ︵○ ~ 喔一 (¯ ﹨○∕ < F >在 ╯╯╲︳ /) ├┤ ∕﹨ ╰O╯ 一刀兩斷──╮¯╰□▽ 我仆 使 ○╯ ╴╴▄▃▆ ╰───凱薩劍!!∕﹨ 街了 ○︵── ╞╡ ∕├╮ ──○﹏↙路面不平,請小心 by P.M -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.124.182.216

06/12 17:12, , 1F
target!?
06/12 17:12, 1F

06/12 17:25, , 2F
event_object.target
06/12 17:25, 2F

06/12 17:25, , 3F
hit(e:MouseEvent) e.target 指向觸發事件的物件
06/12 17:25, 3F

06/12 17:25, , 4F
也是這幾天才學到的招...orz
06/12 17:25, 4F

06/12 17:26, , 5F
e.currentTarget 指向註冊此Listener的物件
06/12 17:26, 5F

06/12 17:31, , 6F
target跟currentTarget好像效果一樣?
06/12 17:31, 6F
文章代碼(AID): #18KEPlBw (Flash)
文章代碼(AID): #18KEPlBw (Flash)