- 官方解释
currentTarget是事件的处理对象(event processor)
target是事件的调用对象(event dispatcher)
- 本人解释
currentTarget就是谁addEventListner了就是谁(不会改变)
target则是谁触发了事件就是谁(看情况改变)
- 请看下面的例子
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
private function init(): void {
this.addEventListener(MouseEvent.CLICK, clickHandler);
}
private function clickHandler(e:MouseEvent): void {
Alert.show("target: " + e.target + "\ncurrentTarget: " + e.currentTarget);
}
]]>
</fx:Script>
<s:Button id="btn1" label="按钮1"/>
<s:Button id="btn2" label="按钮2" click="clickHandler(event)"/>
</s:Application>
P.S.
点击btn1时currentTarget是application,target是btn1。
点击btn2时currentTarget是bt2,target是btn2。