How do you set the position of an AS3 AIR Project window programmatically?
It is simple to do with application descriptor, but I cannot get it to work through code.
All research has lead me to stage.nativeWindow.x = 200;
but this does not do anything for me.
The following has no effect:
public function Main():void
{
stage.nativeWindow.x = 200;
}
Try placing the code in an event handler:
protected function initWindowPosition(event:Event):void {
stage.nativeWindow.x = 200;
}
and listen to an event, such as Event.ACTIVATE:
addEventListener(Event.ACTIVATE, initWindowPosition);
If that doesn't work on it's own, you might also try using the NativeApplication's activeWindow property, in case the stage's nativeWindow
property isn't initialized at the time the ACTIVATE is dispatched:
NativeApplication.nativeApplication.activeWindow.x = 200;