这是我的示例代码
<canvas id="myCanvas" x="200" y="200" height="300" width="500" mouseOver="onOver" />
private function onOver(event:MouseEvent):void
{
trace(mouseX,mouseY);
}
它给我的结果尊重我的应用程序MouseX和MouseY,但我想尊重我的Canvas.please帮助我任何一个
答案 0 :(得分:3)
试试这可能会对你有所帮助
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.core.Application;
private function click(evt:MouseEvent):void
{
var pt:Point = new Point( this.butt.x, this.butt.y );
var global:Point = Application.application.localToGlobal( pt );
trace( "local_x: " + pt.x + " x " + pt.y );
trace( "global_x: " + global.x + " x " + global.y );
var p:Point = stage.nativeWindow.globalToScreen(new Point(this.butt.x, this.butt.y));
trace(p.x + " x " + p.y);
var na:NativeWindow = new NativeWindow(new NativeWindowInitOptions());
na.visible = true;
na.width = 100;
na.height = 100;
na.x = p.x;
na.y = p.y;
na.activate();
}
]]>
</mx:Script>
<mx:Button x="10" y="10" id="butt" label="Click" click="click(event)" />
</mx:WindowedApplication>
答案 1 :(得分:0)
尝试以下追踪: -
trace(event.target.mouseX);
trace(event.target.mouseY);