Air on Netbooks

This question comes in from Tomas about running AIR on Netbooks.


I wanted to know if you personally or through a third-party had experience of Adobe Air running on a netbook. I don't have one of those close to me and wanted to know if it was worth it. At least the resolution is good enough for my app.

Can anyone answer Tomas's question?

I have not had any experience w/ AIR on Netbooks. Although, I know of no reason why it wouldn't work, assuming you have a supported operating system. I suppose there could be potential performance issues.

I love answering questions from readers or podcast listeners, so feel free to send them in.

Lately my writing energies have been pulled between the Flextras Friday Lunch and The Flex Show podcast. If you have questions and want to nail me on them live, drop by the Flextras Friday Lunch. Every Friday at 1pm EST.

How do I uninstall AIR Applications Programatically?

This questions comes in from Krunal and he asks about installing / uninstalling an AIR application from another program.

Can I install / uninstall the air application programatically? Suppose i have a X air application and application have a facility to install / uninstall the Y (air application). Is it possible?

If I understand Krunal correctly, he has an AIR application that he installs as part of another larger installer. When he creates an uninstall routine for the larger program, he wants to uninstall the AIR application too.

To do this "Formally" I think you need to sign up for Adobe's the Runtime Distribution program for AIR. I believe once you're in they'll give you access / information on how to do that.

I believe that the program gives you access to install AIR applications and the AIR runtime in invisible mode, but I could be wrong about that.

All that said, I haven't looked specifically into how AIR applications are uninstalled. I suspect that there is just an executable that you can launch from your custom uninstaller.

If Krunal wants to bundle two different AIR applications together using the default AIR installer / uninstaller, I'm unsure how that would work.

That said, I'm hard at work on the Flextras AutocompleteComboBox and have been blogging less. There is now also a Flextras Blog and I have been holding weekly live Q&A / Demo meetings, every Friday at 1pm EST.

I love answering questions, so if you have one, feel free to Ask away! Or stop by one of the Flextras Friday Lunch demos and stump me in real time.

How do I access a database directly from Flex?

This question came from a reader with no name.


I want to use the remote connection in adobe air (Action Script) to connect the database ( oracle, SQL Server etc...)

My short is answer is that you can't do this.

For a longer answer, Most people use some form of middleware; such as ColdFusion, Java, PHP, Ruby, etc... .

So, build a service in your language of choice to access the database; then use RemoteObject from your AIR app to access those services. I'm not sure if AIR will have crossdomain.xml issues or not.

There was an open source project around at one point which used sockets in the Flash player to run SQL directly against a database. I never got the impression it was production ready, though. And I can't find it in Google right now.

I love the questions that are easy to answer. Do you have one to ask me?

How do I make an AIR Window be always on top?

This question comes in from Martijn:


hi, thanks for posting that stuff about minimizing the adobe air window :) I wondered if you also know if air supports the native window to be "always on top" on your desktop. I can't find anything about the subject. Thanks, Martijn

I've done some experiments with this in the past, but couldn't find my old code. The WindowsApplication tag has an alwaysInFront property.

To make an app always stay on top, just do this:


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" alwaysInFront="true">
</mx:WindowedApplication>

In my experiments, I was testing out AIR to run in Kiosk mode application, so I was also using alwaysInFront with a full screen. You can make things full screen by doing this:


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" alwaysInFront="true"
applicationComplete="onApplicationComplete()">

<mx:Script><![CDATA[
            
public function onApplicationComplete():void{
this.stage.displayState = StageDisplayState.FULL_SCREEN;
}
]]>
</mx:Script>
</mx:WindowedApplication>

Using the ApplicationComplete event, I trigger a function to run this in "large" mode. It just sets the displayState of the stage into Full Screen. You cannot run this code on CreationComplete because the Application stage object is not initialized before the ApplicationComplete event is triggered.

Did I mention I love answering questions? You should feel free to ask away.

Will Adobe Open Screen Project bring Flash to Game Consoles?

Will the Adobe Open Screen Project bring the Flash player to game consoles? Will I be able to create a Flash game and deploy it via Wiiware?

The open screen project removes some licensing restrictions on delivering the Flash Player and also documents a porting layer for the API, making it easier to get the Flash Player working on your device. I do not see Nintendo or Sony or Microsoft on the list of supporters, but I do think this move would make it easier to implement a version of the Flash Player for game consoles. I wonder if a game developer would take the time to do that, or if it has to be done by the console maker?

The implications for a game developer to be able to develop something once and deploy it across consoles and computers consistently is huge. Maybe my next company will be a gaming company. I'm still digesting what this will mean for the community as Flash and Flex Developers.

Ryan's post on the topic also mentioned also mentioned Adobe AIR for devices, which is a new concept for me. Kevin Lynch's video also mentions AIR for Devices.

Using AIR to launch other applications

Lets say you want to open an MS Word file from your web page. You can just link to it using a normal HREF. Browser settings and the operating system will take care of the rest. If it's a PDF, Reader will open. Word will launch for a .doc file. Excel for an excel sheet. ( Or perhaps your browser independent equivalents ).

How do you give the same functionality to an AIR Application? This exact question came up on the Flex Coders list recently and the general concensus was that it could not be done. That surprised me, because I figured you could do something very similiar to what you would do in a web page and let the operating system handle it. This would (I assume) not violate ay security protocols inside AIR. Am I right?

I played around with it and found one solution to the problem. It's far from perfect, though. I accomplished this using the NavigateToURL functionality. The code is really simple, just a button to open the file:


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script><![CDATA[
import flash.net.URLRequest;
        
public function clickButton():void{
var request : URLRequest = new URLRequest('C:\\projects\\test.doc');
navigateToURL(request )    
}
]]>
</mx:Script>
    
<mx:Button click="clickButton()" />
</mx:WindowedApplication>

Click the button, it creates a URL Request and then uses navigateToURL to launch it. In my tests, this will launch a browser instance outside of AIR; and that browser instance will deal with the file, launching word, or a text editor, or whatever depending upon the file.

I can understand how, in some situations this would not be ideal. Perhaps in AIR next we need a navigateToApplication?

How can I find the user's screen size in AIR?

Yesterday, someone posted to Apollo Coders to ask if they can find out the user's screen resolution in an AIR application. The answer is yes, you can.

You can find this information out using the flash.system.Capabilities class. You need to look at the screenResolutionX and screenResolutionY properties. These are static properties on the Capabilities class, so you do not need to create an instance.

The poster also asked if he could find the height and width of the current window. This on was even easier to answer, because windows (and most UI controls ) have a height and width in the Flex framework.

I can demonstrate both of these answers with a single code sample. This code sample will size the application window to 60% of the screen width:


<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
     preinitialize="preInitializeHandler()"/>

<mx:Script><![CDATA[

import flash.system.Capabilities;
import mx.controls.Alert

private function preInitializeHandler():void{
// set the width to 60% of the full screen
this.height = Capabilities.screenResolutionY * .6;
this.width = Capabilities.screenResolutionX * .6;
this.visible = true;
}

]]>
</mx:Script>

</mx:WindowedApplication>

This code is very similar to something I used in a Flex application for a client. It runs code in the preinitialize event. That code sets the height and width of the WindowedApplication to 60% of the screenResolution. Then it makes the window visible. ( I set the window to be invisible in the app.xml file )

As a note, this should work in a Flex app too, but I haven't tried it.

I got a busy week this week. Thursday I'm at a a Microsoft even in Hartford. I understand they are giving out free software. Friday I'm down in NYC to do some podcast interviews at Flex Camp Wall Street.

Accessing command line arguments in AIR!

A question came up over on the Apollo Coders group about how to access command line arguments in an AIR application. I know that there are other explanations + documentation out there on this topic, but I thought I'd regurgitate what I have learned.

In Flex Bulder create an AIR application. I named mine "CommandLine", and the CommandLine.mxml looked like this:


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
</mx:WindowedApplication>

It's an empty app that does nothing, as expected when it is first created. This application will do the brilliant act of displaying the command line arguments using an alert. So, let's add a script block and import the alert.


<mx:Script>
<![CDATA[
import mx.controls.Alert;
                
]]>

</mx:Script>

Arguments are attached the invokeEvent ckass. So, at the top level (WindowedApplication), let's listen to the invoke event:


<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" invoke="onInvoke(event)">

And we'll need to write an onInvoke function inside our script block:


private function onInvoke(event:InvokeEvent):void{
Alert.show(event.arguments.toString());
}

This function is named onInvoke. It accepts the InvokeEvent as an argument. The InvokeEvent has a property named arguments. Arguments is an array. This method converts it to a string and displays it.

Run the app and you'll see an empty alert box. Let's add some arguments. In Flex Builder, if you select the play drop down and go to "run...". The menu will look something like this:

And it will bring up this configuration screen:

You'll notice the config screen has a place for command line arguments. In this situation I typed test=test, test2=test1 . So far as Flex is concerned, Command line arguments are separated by a space; so I get two command line arguments: "test=test," and "test2=test1".

A few things that you might want to be aware of:

  • The invoke event is fired every time the application is launched, either by double clicking a shortcut or by double clicking the .exe file (or whatever your preferred method of choice is for launching an application). It does not matter if the application is already loaded, the invoke event will be re-run. You may want to write logic to prevent the app from initializing the command line arguments twice.
  • I'm not sure how to add command line arguments to the AIR Application shortcuts as part of the AIR installation process. Does anyone know? In my situation, the AIR app is being launched by another application, so that application handles creating and passing the command line arguments.
  • In it's current form, there is no concept of named arguments. So, the arguments in my above example are "Test=test". I do not have an argument named "test" with a value "test". I bet you could write a parser using regex and a Dictionary to generate your named arguments. Maybe I'll experiment with this at some future time.

The link I saved to the original thread is here although it does not appear to be working at the time of this writing. Maybe I got the link wrong. I currently have 11 things on my list of "writing ideas" and sometimes it takes a while for this stuff to peculate.

Upgrading to Flex Builder 3

I just got the chance to upgrade from Flex Builder 3 Beta 3 to Flex Builder 3 Gold and along the way I also upgraded an application from AIR AIR 1.0 . My upgrade this time was very smooth.

First, as always I strongly recommend reading the release notes all the way through. Do it twice.

The Adobe Partner portal only has the stand alone version, so it took a little searching to find the plug in version. I'm not sure why plug in and stand alone are not on the same page of the public site.

This time I actually used the -clean feature of eclipse to save all my previous work spaces. I'm glad I did; that was a brilliant move. Saved me a ton of time since I have dozens of work spaces.

My AIR application only needed one tweak to the -app.xml config file. I had to change the descriptor from "1.0M6" to "1.0". I figured there would be a change like this along the lines, but I could not find it documented anywhere. I created a new application file and visually compared the Beta 3 XML descriptor with the 1.0 descriptor.

All good stuff!

Reviewing My 360Flex Survey Results

The 360Flex have posted the results of session surveys. Here are mine. Based on a few other speakers I spoke to, I got a lot of responses (20 once you discount the joke review I filled out for my own session).

I thought my session went great, and was in a room with 40-50 people or so. I felt I was able to facilitate a discussion with my attendees (as opposed to just lecturing them), which is what I aim for. I was really worried about having to "repeat the questions", which the ""signers" asked me to do so they could relay to the hearing impaired attendee. But, I think I did pretty good with that.

A few comments that I felt were worthy of mention:


Very nice personality; funny and easy to listen to.

This is a huge boost to my ego. I don't usually think of myself as funny (although I can be sarcastic), but I'm glad you were entertained.


...he was able to facilitate the audience for answering those he did not have knowledge on.

Good conversational communication style

This is the vibe I shoot for when presenting, so I'm glad that at least two person 'got it' and enjoyed it.


He didn't think AIR was broady applicable

This is true, and I'm not ashamed to say it. In fact I did say it in the intro to my presentation. I do not think AIR 1.0 is primed up for wide adoption. The business case for AIR, as I see it, is that it makes it very easy to write "Partially Connected" applications.


More for beginners.

I was very torn whether to tell John and Tom that my preso was a "100" level or "200" level. I went with 200 level. Maybe I shouldn't have. I went with 200 because there is a lot of code that I just glaze over because it was not the focus of the presentation. However, the beginning of my preso deals with things such as "What is AIR and why do we care?" and "Why do we care about code reuse?" That is very intro stuff. However, I made the audience answer those questions to make sure we were on the same page moving forward.


ppt skillz = -1

Oddly someone else said that the slides were useful. The presentation was not about powerpoint, and I think I used it well enough to communicate what I needed to communicate. I'm fine with not being a powerpoint wizard.


He had a hard time answering alot of the questions. It seems like he was relatively new the Flex. I felt like the attendees wanted more answers than he was able to give.
This was sentiment echoed a couple times in the comments, and that surprised me. There was a question or two that I didn't have answers to. I wish I remembered what they were. I don't remember being totally clueless, though. I'd rather say "I don't know" than to BS an answer so I look like I know stuff.


Was a little short

I find it hard to fill up fifty minutes worth of time. 80 minutes scares me. I've spoken to other presenters who have expressed chagrin about the 80 minutes presentations. However, I also know many presenters who could fill up 3 hours without a second though.

And for those that read this far, thank you! Postcards for The Flex Show will be making appearances in the attendee swag bag at two separate Flex Camps:

There is a chance (schedule permitting) that I'll be at Flex Camp Wall Street recording interviews for The Flex Show, although I'm out of the office the day before it for a separate event, so I'm not sure. But Mike Labriola said he used to have my laptop model and may have some extra batteries I could "acquire" from him, so...

I need to figure out April's schedule. Are you going to be at Flex Camp Wall Street? Would you like to listen to me podcast (live) from Flex Camp Wall Street?

More Entries

All Content Copyright 2005, 2006, 2007, 2008, 2009 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version 5.9.2.002.