Swa*_*ngh 4 apache-flex flash actionscript-3
我真的不明白这两者之间的区别
event.target and
event.CurrentTarget and explanation.
Run Code Online (Sandbox Code Playgroud)
有人可以用一个简单的例子向我解释这一点吗?
假设您创建一个TextInput对象。
import fl.controls.TextInput;
import flash.events.MouseEvent;
var t:TextInput;
function init():void {
t = new TextInput();
t.x = 100;
t.y = 100;
t.width=100;
t.height=30;
t.addEventListener(MouseEvent.CLICK, fresult);
this.addChild(t);
}
function fresult(e:Event):void {
trace(e.target);
trace(e.currentTarget);
}
init();
Run Code Online (Sandbox Code Playgroud)
单击 TextInput 会显示以下痕迹:
[对象文本字段]
[对象文本输入]
这意味着:
event.target是事件起源的对象。即在本例中,单击了 TextField,因此该事件源自TextField.
event.currentTarget是调用侦听器的对象。在这种情况下,被TextInput称为监听者,所以currentTarget是TextInput
| 归档时间: |
|
| 查看次数: |
13185 次 |
| 最近记录: |