In a previous example, “Opening a new Window in Adobe AIR”, we saw how you could launch a new Flex Window container in Adobe AIR by creating a custom Window component and calling the open() method.

The following example shows how you can control whether the newly opened window receives focus and becomes active by setting the Boolean openWindowActive attribute to the open() method.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2010/03/12/specifying-whether-a-new-window-is-focused-in-adobe-air/ -->
<mx:WindowedApplication name="Window_open_openWindowActive_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            import mx.core.Window;
 
            protected function btn_clickHandler(evt:MouseEvent):void {
                var win:MyWin = new MyWin();
                win.open(ch.selected);
            }
        ]]>
    </mx:Script>
 
    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="ch"
                label="openWindowActive:"
                labelPlacement="left"
                selected="true" />
    </mx:ApplicationControlBar>
 
    <mx:Button id="btn"
            label="Open Window"
            click="btn_clickHandler(event);" />
 
</mx:WindowedApplication>

And the custom Window component, MyWin.mxml, is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2010/03/12/specifying-whether-a-new-window-is-focused-in-adobe-air/ -->
<mx:Window name="MyWin"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="absolute"
        width="300" height="200">
 
    <mx:Label id="lbl"
            text="I'm a Window!"
            fontSize="32"
            horizontalCenter="0" verticalCenter="0" />
 
</mx:Window>
Tagged with:
 

One Response to Specifying whether a new Window is focused in Adobe AIR

  1. gourav says:

    hii

    thanks its good example and very eagy

Leave a Reply