I am trying to obtain the actual mouse co-ordinates on the screen so I can create a Native Window at that position but I dont seem to be able to find the right way to do this correctly.
I have tried various things, the closest thing I have at the moment is:
this.contentMouseX and this.contentMouseY
This gives me the coords on the current stage which is fine, then I add to that the:
NativeApplication.nativeApplication.activeWindow.x and activeWindow.y
Which is close, but this doesnt take into account the application title bar.
There must be an easier and more straightforward way of doing this I am sure, can anyone give advice cos I fail to find it on google?
I have tried localToGlobal which doesnt work, it seems that 'global' means within the application and not global to the screen which is of no use to me. Here is an example that shows the failure...
<?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.contentMouseX, this.contentMouseY );
var global:Point = Application.application.localToGlobal( pt );
trace( "local_x: " + pt.x + " x " + pt.y );
trace( "global_x: " + global.x + " x " + global.y );
}
]]>
</mx:Script>
<mx:HBox horizontalAlign="center" width="100%">
<mx:Button id="butt" label="Click" click="click(event)" />
</mx:HBox>
</mx:WindowedApplication>