1 package { 2 3 import flash.display.Sprite; 4 import flash.events.MouseEvent; 5 import fl.controls.Label; 6 public class tevent extends Sprite { 7 public function tevent() { 8 trace("bb"); 9 this.mouseEnabled = false;10 this.mouseChildren = true;11 var __Sprite:Sprite = new Sprite();12 __Sprite.graphics.beginFill(0xFF0000);13 __Sprite.graphics.drawRect(0,0,300, 300);14 __Sprite.graphics.endFill();15 __Sprite.mouseChildren = true;16 __Sprite.x = 240;17 __Sprite.y = 10;18 this.addChild(__Sprite);19 //__Sprite.addEventListener(MouseEvent.MOUSE_MOVE, handler_click);20 var __shape:Sprite = new Sprite();21 __shape.graphics.beginFill(0x000FF0);22 __shape.graphics.drawRect(0,0,100, 100);23 __shape.graphics.endFill();24 __shape.x = 150;25 __shape.y = 150;26 __Sprite.addChild(__shape);27 //this.addEventListener(MouseEvent.CLICK, handler_click); 28 29 __Sprite.addEventListener(MouseEvent.CLICK, handler_click);30 var lb1:Label=getChildByName("lb1") as Label;31 var lb2:Label=getChildByName("lb2") as Label;32 var lb3:Label=getChildByName("lb3") as Label;33 var lb4:Label=getChildByName("lb4") as Label;34 function handler_click(e:MouseEvent):void35 {36 lb1.text=String(e.localX); //此处主语是event,也即MouseEvent,也就是说是【当前鼠标单击事件目标test_mc】的内部坐标37 lb2.text=String(e.currentTarget.mouseX); //此处主语是event.currentTarget,也即test_mc,也就是说是test_mc的内部坐标38 lb3.text=String(e.target.mouseX); //此处主语是target39 lb4.text=String(e.stageX);40 //trace("----------------");41 //trace(__shape.mouseX); 42 }43 44 45 }46 }47 48 }