The following example shows how you can launch a new Flex Window container in Adobe AIR by creating a custom Window component and calling the open() method.

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:WindowedApplication name="Window_open_test"
            import mx.core.Window;
            protected function btn_clickHandler(evt:MouseEvent):void {
                new MyWin().open();
    <mx:Button id="btn"
            label="Open Window"
            click="btn_clickHandler(event);" />

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

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:Window name="MyWin"
        width="300" height="200">
    <mx:Label id="lbl"
            text="I'm a Window!"
            horizontalCenter="0" verticalCenter="0" />
Tagged with:

9 Responses to Opening a new Window in Adobe AIR

  1. Bhaskar says:

    Why you are still using halo components? you can use spark right?

    • Peter deHaan says:


      You can use Spark components or the old MX components. I was still using MX since Flex 4 wasn’t officially released yet, but I’ll switch over to Spark components now that Flex 4 is out (see the official Flex Team blog post at “Flex 4 SDK and Flash Builder 4 final releases are here…”).


  2. Tahir Alvi says:

    I want to know that what is method to make a costume title bar in flash builder 4?


  3. feresr says:

    Hi! i’m sorry. but can’t get this working.. i don’t know what i’m doing wrong..

    this is the error:

    access to an undifined proprety MyWin

    could you tell me what i’m doing wrong?


  4. feresr says:

    oh!.. i did copy the second block.. but i didn’t name it as MyWin.mxml.. that may be the Error..

    Thank you for answering me. !.

  5. feresr says:

    Hi again, I’m sorry but i still have some problems with this code… and i think it’s because of my windows’ code.. it doesn’t look like yours.

    This is what i mean:
    Your code:

    My code:

    As you can see, the only difference is that little ‘s:’ at the begining of my code. I can’t change it because my whole windows has components.

    Flex created these tags. And i don’t know why…

    This is the Error i’m getting now: ‘Call to an undefined method open’.

    I hope you know the aswer :) and i’m apologize for my english. I’ts not my native language.

    Ow! and by the way.. could you tell me what’s the name of the font you have in the header of the web site (‘A bunch of Adobe Air…’).

    Thank you! And congratulations for the website.

  6. Feresr says:

    I discovered what i was doing wrong… This example was really useful. Thanks. Bye

  7. Hollywood says:

    thanks very much for the post, very helpful, but how do you communicate or send data back and forth between the parent application and the newly created window. thanks

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam Protection by WP-SpamFree