Skip to content

Instantly share code, notes, and snippets.

@audinue
Created February 3, 2016 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save audinue/54e082e32a00f9113ded to your computer and use it in GitHub Desktop.
Save audinue/54e082e32a00f9113ded to your computer and use it in GitHub Desktop.
Drag move NativeWindow manually in AIR (doesn't use NativeWindow.startMove()).
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.display.NativeWindow;
var down:Boolean = false;
var offset:Point = new Point();
stage.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void {
down = true;
var p:Point = new Point(e.stageX, e.stageY);
p = stage.nativeWindow.globalToScreen(p);
offset.x = p.x - stage.nativeWindow.x;
offset.y = p.y - stage.nativeWindow.y;
});
stage.addEventListener(MouseEvent.MOUSE_MOVE, function(e:MouseEvent):void {
if(down) {
var p:Point = new Point(e.stageX, e.stageY);
p = stage.nativeWindow.globalToScreen(p);
stage.nativeWindow.x = p.x - offset.x;
stage.nativeWindow.y = p.y - offset.y;
e.updateAfterEvent();
}
});
stage.addEventListener(MouseEvent.MOUSE_UP, function(e:MouseEvent):void {
down = false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment