这是我的示例代码
<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。请帮助我任何人
这是我的示例代码
<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。请帮助我任何人
试试这个可能对你有帮助
<?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>
尝试以下跟踪: -
trace(event.target.mouseX);
trace(event.target.mouseY);