Adobe AIR

Adobe AIR Getting your Application Version

I couldn’t believe how hard this was to find. If you are programming with Javascript and HTML in Adobe AIR you might want to know what version your application is (the runtime has it’s own version). If you want to get it out of the XML application descriptor then you need to parse the XML file.

Personally I hate XML. Mostly because they made the brain dead decision to allow white space BETWEEN TAGS to count as a node. I don’t know who thought that was a good idea but it makes processing XML files REALLY hard and it encourages creating unreadable files that have no formatting.

But, here’s a simple function modified to allow you to pull the application version:

[js] /**
* getAppVersion
* gets the application version from the application descriptor
* Just for the record, I hate XML.
* @returns ver {string} The application version as a string
function getAppVersion() {
var xmlString = air.NativeApplication.nativeApplication.applicationDescriptor;
var appXml = new DOMParser();
var xmlobject = appXml.parseFromString(xmlString, "text/xml");
var root = xmlobject.getElementsByTagName(‘application’)[0];
var appId = root.getElementsByTagName("id")[0];
var appVersion = root.getElementsByTagName("version")[0];
var appName = root.getElementsByTagName("filename")[0];
air.trace("appId: " + appId);
air.trace("version: " + appVersion);
air.trace("filename: " + appName);
return appVersion;
[/js] ## Why I like AIR

I have become enamored with Adobe AIR ( because it lets me leverage my web programming for the desktop.  In college a classmate of mine once postulated his theory for the “Conservation of Stupidity”.  It goes like this, there is a finite amount of ignorance we all must carry around with us for our entire lives.  In order maintain that level every time we learn something new, we have to jettison something old.  The trouble is the brain doesn’t consult with us before it dumps the old to make room for the new.

For me, that theory manifests itself when I’m learning a new programming language.  I just love my children too much to run the risk of forgetting their names so I can learn a new programming language.  In reality, the real issue is that it takes time to get good at a programming language.  And it is really annoying to have to learn a new programming tool change, process, framework just so I can apply it in a new arena (e.g. the desktop).  Enter AIR.  With AIR (in theory) I don’t need to learn anything new.  At least as far as programming languages go.

I’ve started to have some fun with WordPress plugins and my new favorite Javascript API JQuery.  I know Microsoft has some fantastic free tools, but I work on a Mac and all my websites are Linux based so no C-Sharp for me.

As for Apple, while I love my Mac, the overhead of learning CoaCoa doesn’t translate well into the web.  Of course there’s flash, but well… it’s Flash, and that too has it’s features.  But the real reason I like web programming is that modern browsers are so powerful, you can make some really sophisticated user interfaces and skin them with a few lines of Javascript, HTML and CSS.  And AIR lets me do that, but being Adobe they have a heavy preference for all things Flash and Flex.  Me, I like Javascript and PHP.  While they are supported there seems to be more examples of F/F than J/P.

So if I find something useful, I’m hoping the web crawling spider bots pick it up and share it.

— Scott

Published by