事件的target和currentTarget的区别

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    
<mx:Script>
        
<![CDATA[            
            private function onClick(event:MouseEvent):void
            {
                trace("event.target:" + event.target);
                trace("event.currentTarget:" + event.currentTarget);
            }            
        
]]>
    
</mx:Script>
    
<mx:Canvas id="outermostContainer" width="324" height="215" click="onClick(event);" 
        backgroundColor
="#00BB00">
        
<mx:Canvas  id="canvasContainer" width="249" height="108" click="onClick(event);"
            backgroundColor
="#00FF00" >
            
<mx:Button id="btnTest" label="点击测试"  fontSize="25" x="59.5" y="34" />        
        
</mx:Canvas>        
    
</mx:Canvas>
</mx:Application>

<!--
target 和 currentTarget

currentTarget: The object that is actively processing the Event object with an event listener. 
For example, if a user clicks an OK button, the current target could be the node containing 
that button or one of its ancestors that has registered an event listener for that event. 

currentTarget: 事件监听器(监听函数)中当前正在处理事件的对象。例如,如果一个用户点击OK按钮,
currentTarget可能是Button或者Button的容器(前提是该Button或者容器都注册了鼠标点击事件)
注:Button的"容器"是指显示列表中Button节点的父节点。

target: The event target. This property contains the target node. For example, if a user clicks
 an OK button, the target node is the display list node containing that button.
 
target: 事件对象. 该属性保存了事件对象。例如,如果用户点击了Button,target就是Button本身。
-->
posted @ 2009-06-22 14:57  RIA爱好者  阅读(707)  评论(0编辑  收藏  举报