Sunday, March 27, 2011

Working with windows in AIR: Part 1

Today we will start learning about windows in our AIR application.

There are two main classes you need to know about to start working with windows. Those classes are flash.desktop.NativeApplication and flash.display.NativeWindow. The first class is created once the application is opened (you can't create it manually) and is basically the whole application. It can contain one or more windows. The windows, which are NativeWindow class objects, can be created manually, and one window - the main one - is also created when the application is started.

To create a NativeWindow object, you first need to define the necessary parameters for the window. That can be done using the flash.display.NativeWindowInitOption object, which has several parameters you can specify.

The main properties of the NativeWindowInitOption class are type, systemChrome and transparent.

The type property has 3 possible values: NativeWindowType.NORMAL, NativeWindowType.UTILITY, NativeWindowType.LIGHTWEIGHT. The NORMAL is basically a typical window, that uses full-size chrome and appear on the OS taskbar. The UTILITY type is a more basic type of window. It uses a simpler version of the system chrome and does not appear on taskbars. The LIGHTWEIGHT type doesn't have any chrome and does not appear on taskbars. Which one of the three to use? The one that suits your needs best.

The systemChrome property has two values: NativeWindowSystemChrome.NONE and NativeWindowSystemChrome.STANDARD. If you choose STANDARD, the window will be similar to any other system window of your OS. If you choose NONE, the window will not have any interface and you won't be able to use such pre-built features of a standard window, like maximize, minimize, close, move, resize etc. and if you want those features to be in your application, you'll have to program them yourself.

The transparent property is a boolean and defines whether the background of your application is transparent or not. If you set it to true, you can, for example, draw your own shape of a window (like an oval, or a rounded rectangle). However, if you want to set transparent to true, you will have to set systemChrome to none.

Additionally, there are other optional properties for the NativeWindowInitOption object, and those are: minimizable, maximizable and resizable. They are all booleans and by default, they are all set to true.

In the next tutorial we will learn how to actually create a secondary window from our application.

Thanks for reading!

Related:

Working with windows in AIR: Part 2
Working with windows in AIR: Part 3
Working with windows in AIR: Part 4
Working with windows in AIR: Part 5
Working with windows in AIR: Part 6
Working with windows in AIR: Part 7
Working with windows in AIR: Part 8
Working with windows in AIR: Part 9
Working with windows in AIR: Part 10
Working with windows in AIR: Part 11
Working with windows in AIR: Part 12

No comments:

Post a Comment