Non Standard (Custom) Window in AIR
May 27th, 2008Monstagon was wanting to create a custom window for an AIR application at work and could not figure out how to do it. I had found a tutorial that used an apple shaped window, but I seem to have lost the bookmark. So I figured I’ll just post my own tutorial. Since that is what this dang blog is for!
First, create a new AIR application in Flex Builder. I called mine NonStandardGUI, but you can call it “whatever.” Then, open up the app-XML file (“NonStandardGUI-app.xml”) and we will edit the properties here first. This file is loaded automatically and contains all of the basic application properties. Set these properties to
systemChrome = none transparent = true visible = false width = 800 height = 600 x = 100 y = 100
in the “initialWindow” section. The width, height, x and y are optional; you just need to make sure the size is big enough for the background image and the location on the screen allows you to see the whole window.
Now we will edit the NonStandardGUI.mxml (the main application file). To the WindowedApplication, add these attributes
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
showTitleBar="false" showStatusBar="false"
backgroundAlpha="0.0" borderThickness="0" >
This gets rid of the window. If you were to save and run the app now it would display nothing.
To add your image as the background, simply an Image tag with the source pointing to the actual image file. For better performance, we want to embed these static images. This could be a PNG, JPG, SWF… So the background can be anything you can create.
<mx:Image id="background" source="@Embed(source='nonStandard_GUI_test.png')" />
With the image in place a a background, you can add all the content you like to it. Due to the nonstandard shape of the new window, laying content out might be a little more time consuming since the Flex Builder Design view doesn’t load the image for you. I have attached the source code for my NonStandard GUI for you to dissect.
Source code: nonstandardgui.zip
