关于target currentTarget 属性的解析(官方收集)

这是从官方的文章中感觉重要的一个个片段中截取出来的,可能有些东西不是一个页面的。也许有的是在说明Flex时说的,也许是在解说AS3时候说的。

自己感觉挺不错的,就收集了起来。

自己尝试过翻译一下下面的文章,但总是感觉不够“原汁原味” ,其中的单词并不难,有兴趣的可以看看吧。


About the target and currentTarget properties

Every Event object has a target and a currentTarget property that help you to keep track of where it is in the process of propagation. The target property refers to the dispatcher of the event. The currentTarget property refers to the current node that is being examined for event listeners.

MouseEvent events bubble up the parent chain, and can be handled on any ancestor. As the event bubbles, the value of the event.target property stays the same (UITextField), but the value of the event.currentTarget property is set at each level to be the ancestor that is handling the event. Eventually, the currentTarget will be Button, at which time the Button control's event listener will handle the event. For this reason, you should use the event.currentTarget property rather than the event.target property

Capturing phase

During the capturing phase, Flex changes the value of the currentTarget property on the Event object to match the current node whose listener is being called. The target property continues to refer to the dispatcher of the event.

Targeting phase

In the targeting phase, Flex invokes the event dispatcher's listeners. No other nodes on the display list are examined for event listeners. The values of the currentTarget and the targetproperties on the Event object during the targeting phase are the same.

Bubbling phase 

In the bubbling phase, Flex examines an event's ancestors for event listeners. Flex starts with the dispatcher's immediate ancestor and continues up the display list to the root ancestor. This is the reverse of the capturing phase.

During the bubbling phase, Flex changes the value of the currentTarget property on the Event object to match the current node whose listener is being called. The target property continues to refer to the dispatcher of the event.

When Flex invokes an event listener, the Event object might have actually been dispatched by an object deeper in the display list. The object that originally dispatched the event is the target. The object that the event is currently bubbling through is the currentTarget. So, you should generally use the currentTarget property instead of the target property when referring to the current object in your event listeners.






  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值