Set AIR window position programmatically?

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;
    }

Answers


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;

Need Your Help

How to use ZF2's EventManager over multiple classes (and modules)?

php zend-framework2

I am having the following setup: In a controller I trigger an event and I want to attach multiple listeners to it at other places.

.getScript() equivalent in MooTools?

javascript mootools

I was wondering if there is a MooTools equivalent to jQuery's .getScript()? I'm pretty certain that this exists somewhere in MooTools but I haven't been able to find it yet.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.