When progamming an AIR application, you may want to make use of the applicationStorageDirectory available via the flash.filesystem package to store temporary files/folders. You can find where your system is storing these files by doing something like the following:
trace(f.nativePath + ' is where my file is stored');
var f:File = File.applicationStorageDirectory.resolvePath("Test.txt");
This will give you an absolute path to the local system file storage location. Handy for multi platform applications, as Pc and MAC based systems will use different default storage directories.
I was sure I had done this before, somewhere but I couldn't find the code anywhere. So I've knocked together a really quick and simple example.
I want to be able to open a new site in a pop up from an AIR application. To do this I need to use the 'urlRequest' function to create a url request. Then insert that into a 'navigateToURL' method, specifying that you want a new window '_new'.
Here is the complete example.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
public function goToUrl(link:String):void
var urlRequest:URLRequest = new URLRequest('http://' + link);
<mx:Canvas x="10" y="10" width="321" height="146" backgroundColor="#FFFFFF">
<mx:Form x="10" y="52">
<mx:Button x="10" y="114" label="Go to" click="goToUrl(urlTxt.text)"/>
<mx:Label x="10" y="10" text="New Window test" />
Works like this.
Whilst creating my last AIR application I found that the standard 'Chrome' that is provided by the OS just didn't match the application look and feel at all.
After a little searching I found that there are a few key elements in your application that you need to change to remove the standard operating system Chrome, and stop Flex builder from replacing it with its own.
Firstly in your application-app.xml document look for the 'systemChrome' xml value. Setting this to none will disable the operating system Chrome. As we are using the 'WindowedApplication' Flex builder will automatically start using its own Chrome framework, so we need to turn that off too.
<!-- Whether the window is transparent. Only applicable when systemChrome is none. Optional. Default false. -->
This is done in the WindowedApplication code, set showFlexChrome="false" and that will disable Flex from using its default Chrome.
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()" showFlexChrome="false">
Now that we have completely turned it all off, we need to build our own. In this application I am using a canvas with rounded corners that is 15 pixels larger than the application canvas, to give the impression of a border all the way around. Inside that canvas I've added two controls.
<mx:Label text="X" styleName="controls" toolTip="Close" x="184" y="1" click="onClose()" />
These simply replicate the functionality that the minimise and close buttons give a user on a standard window. The functions they call are:
public function onClose():void
public function onMinimize():void
And with that you fully customise the look and feel of your applications Chrome.