Search code examples
airscreensaver

Can I create Windows screen saver with Adobe AIR?


Is it technically possible to create a screen saver for Windows using Adobe AIR?


Solution

  • Yes it is.

    What you can do is compile your AIR project with -captive-runtime OR -target bundle (Makes it a standalone .exe instead of .air file).

    For windows, simply rename your .exe to .scr, right click and choose install or test.

    If you want to set it up for configuration and preview modes, you can listen for the application invoke event:

        //put this in your app main constructor
        NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, invokEventHandler, false, 0, true);
    
        protected function invokEventHandler(e:InvokeEvent):void {
                //you don't actually have to loop as it will always be the first argument
                for each(var a:String in e.arguments) {
                    //p - Show the screensaver in the screensaver selection dialog box
                    if (a.indexOf("/p")) {
                        //do something different for preview mode
                        break;
                    }
                    //s - Show the screensaver full-screen
                    if (a.indexOf("/s")) {
                        //the main full screen mode
                        break;
                    }
                    //c - Show the screensaver configuration dialog box
                    if (a.indexOf("/c")) {
                        //show a configuration window
                        break;
                    }
                }
        }