加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

AS3中Event的target和currentTarget的区别

发布时间:2020-12-15 01:24:09 所属栏目:百科 来源:网络整理
导读:真正的事件dispatch者是event.target,监听事件(addEventListner)的对象是event.currentTarget, Flex skd中有言曰: "Event objects also have target properties that reference the actual object which dispatched the event. In some cases,the target

真正的事件dispatch者是event.target,监听事件(addEventListner)的对象是event.currentTarget,Flex skd中有言曰:


"Event objects also have target properties that reference the actual object which dispatched the event. In some cases,the target may not be the object for which you have registered a listener. This can occur when the object for which you have registered a listener contains a child component that also dispatches the same event (and

the event bubbles). If you want to ensure that you are getting a reference to the object for which the listener is registered to listen for the event,use the currentTarget property"

例:如为容器mc1创建了一个同类型(或者说拥有相同事件)的子容器mc2,再为mc1注册click事件监听器,当单击子容器mc2时,则event.target指事件dispatch者mc2,而event.currentTarget指当前的事件处理者mc1,因此在使用时如果是要获取被注册事件监听器的对象(一般都是如此)则用event.currentTarget,currentTarget属性应具备两条件,一是它注册了侦听器,二是正在处理事件。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读