Using Titanium to do things AIR can’t do …
Adobe AIR is a extraordinary platform and the core idea behind AIR i.e enabling web developers to build desktop apps has been revolutionary. But, there are things about AIR that are very limiting as a developer … many real world applications need much more interaction with the desktop than AIR allows, yes Adobe has valid security related reasons not to allow this but once users allow you to install an application on their desktop they expect features that AIR doesn’t allow you to implement … not being able to do trivial things like .. launch a file in its default application or register a global keyboard shortcut is sometimes frustrating and has led to developers putting together things like The Merapi Project .. which quite frankly is a hack to work around the core problem .. inextensibility of AIR as a platform.

This is exactly why Titanium, although very new and not entirely mature, is extremely interesting as an option to deploy desktop applications developed using web technologies. Titanium has this concept of Modules that allows you to extend the run time in any which way you like. Besides that, Titanium, just with the bundled in set of modules, is much more friendly with the desktop and has features like invoking applications, starting and controlling processes etc.
I’ve built a simple Application Launcher as an example that uses Flex/Flash as the front-end technology and Titanium as a runtime. Launcher can be used to launch any application that is installed on your system .. this is something that cannot be built with AIR.

Here’s the source ..
Just like several other times when dealing with ExternalInterface Abdul’s Javascript MXML Tag was very useful.
Compiled Distributable for OSX
(I haven’t compiled the Linux and Windows versions since Jeff Haynie told me on IRC that Titanium is releasing PR3 today that will allow cross platform compilation from any one platform .. so i will post the other distributables tomorrow)









March 23rd, 2009
I’ve been following titanium for a while. Seems like it will be pretty interesting once it gets a bit more stable.
Download link for OSX app is broken.
Thanks
March 23rd, 2009
Hii Mrinal !
Unfortunately when I tried to run your sample APP it started but as soon as I clicked on Run Application button it throws an error and resulting in unusable.
This is the error I am getting and I tried to change the browser from Preferences but didn’t work .
I am excited to see it in action so can you please re-code it or make a stable code ?
March 23rd, 2009
sorry I had forgot to list the error .. here it goes -
Error: Error #2067: The ExternalInterface is not available in this container. ExternalInterface requires Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime.
at Error$/throwError()
at flash.external::ExternalInterface$/call()
at Launcher/runProcess()[C:\Documents and Settings\amar\My Documents\Flex Builder 3\Launcher\src\Launcher.mxml:12]
at Launcher/__run_click()[C:\Documents and Settings\amar\My Documents\Flex Builder 3\Launcher\src\Launcher.mxml:46]
March 23rd, 2009
Amar .. how are you running the app?
You should be using the Launcher.app file included in the download code http://weblog.mrinalwadhwa.com/wp-content/uploads/2009/03/srcview/Launcher.zip inside Launcher/src/Launcher/dist/osx/Launcher.app
March 23rd, 2009
@Nemanja
Sorry about that, turns out my webserver doent support hosting .app files .. maybe I need to add a MIME type or something … in the meantime you can download the source zip http://weblog.mrinalwadhwa.com/wp-content/uploads/2009/03/srcview/Launcher.zip
The Launcher.app is located in the zip at Launcher/src/Launcher/dist/osx/Launcher.app
March 23rd, 2009
Last I checked, I thought i remembered that Titanium was JS only, did they change that? Anyway, very interesting developments coming. I’ve never liked how non-native the air environment was, even if only viewed an aesthetics standpoint.
Can’t get your app to run. It says it’s missing an installer or something
March 23rd, 2009
I’ve fixed the download for now by putting the Launcher.app in a zip
http://weblog.mrinalwadhwa.com/wp-content/uploads/2009/03/srcview/source/Launcher/dist/osx/Launcher.app.zip
To Install .. download this file, unzip Launcher.app.zip to get Launcher.app and drop that into your Applications folder.
March 23rd, 2009
Hey Mrinal !
I am using Windows PC not MAC so I don’t think that I need to follow the above said instruction .. isn’t it ?
Second thing I tried once more like exporting release build and then tried to run but again same problem . Same error as I already posted .
Thanx for the quick reply Mrinal and again am waiting for another reply
March 23rd, 2009
@Sean Nope its still JS only, it’s a Webkit container and can run Flash content inside an html page… so that I just used ExternalInterface to call their JS API to interact with the runtime
The app seems to work fine on my system .. maybe I did not package it right … will check.
Could someone else with OSX confirm as well if it working or not.
Mrinal
March 23rd, 2009
@Amar Titanium creates different distributables of the app for differnet OS … I have only posed an OSX version of the application … see note below the download link in the post … I will post the other versions after the Titanium PR3 release today
March 23rd, 2009
RT @peterelst Using Titanium to do things AIR can’t do … http://is.gd/oy9f
March 23rd, 2009
Thanx Mrinal !
I’ll wait for the Titanium with Flex example for windows . It would be more nice if you could write a beginner level tutorial for AIR with Titanium getting started and the application should be somewhat bigger so that we could see more uses of Titanium APIs
March 23rd, 2009
Am currently using Merapi to overcome shortcomings of AIR. You’re 100% correct about accessment of AIR. There’s enough to get really excited about (particularly if you already are a Flex developer), yet the reality of what there is not enough to write the kind of desktop apps that one wants to really write.
In our case using Merapi was not so bad as we had to have Java 6 JRE around anyway to run our legacy Oracle Forms apps (the client for that is a Java applet). So we launch a Java program, which in turn launches our AIR program, which in turn uses Merapi to launch our legacy app – or other desktop apps.
What is super frustrating about AIR is dealing with the sandboxes and the limitations of the i/o classes. So I want to load a Flex application from a web site. Flex SDK 3.2 has sub-applications feature to enable that – SWFLoader is primary API to use when loading a remote Flex .swf file from a web site. This loads the remote Flex app into a remote sandbox with respect to the AIR application sandbox. You then use a bridge to interact.
The maddening thing, though, are the Flex i/o classes, such as HttpService and SWFLoader. My web site uses Spring Security to redirect any unauthorized access to a login page. This all worked great when running our Flex app in a browser. Yet now I need to be able to get and set cookie headers. Try getting cookie header from an HttpSerivice call or setting a cookie header on SWFLoader prior to loading a .swf file when in AIR application sandbox.
This kind of stuff makes programming in Adobe AIR utterly maddening.
Stuff that worked perfectly fine for Flex apps running in a browser become utterly torturous to deal with from AIR.
March 23rd, 2009
only one thing, the size of compiled package is too large!
March 23rd, 2009
@pickerel the Launcher.app is currently about 1 MB in size but I believe it can be made smaller .. since I’m new with Titanium, I think I included packages I did not need while packaging.
Mrinal
March 23rd, 2009
Mrinal,
I’ve tried downloading both zip packages but Launcher.app gives me this error in both cases. I’ve tried running it from /Applications folder, but I get the same error.
Application Error
Missing installer and application ahs additional modules that are needed.
March 23rd, 2009
@Namanja I checked with the Titanium team on IRC and apparently all the install issues should be fixed after the PR3 release scheduled for later today .. I’ll repackage and share the new version as soon as I can.
Thanks
Mrinal
March 24th, 2009
With Titanium it is possible to open excel, word, ppt and pdf documents within the AIR application. Screen Capture?
March 24th, 2009
@Air Interesting article detailing the differences between Air & Titanium (http://tr.im/hJTf). Will Air 2.0 resolve some of those issues?
March 25th, 2009
@srinath
Titanium and AIR are different runtimes .. what you said ..using titanium to open something “within” an AIR application does not make any sense since you’re either using AIR or using Titanium
PDF – is native to AIR and you can open/manipulate PDFs inside AIR
excel, word, ppt — you should be able to open these in AIR as well, after all they are just files .. after you can read it though you’ll need to understand and interpret teh format somehow.
I’m not sure if Titanium can be used to do a screen capture .. would have to figure out if a c++ module can be used to capture .. not sure
March 29th, 2009
I posted something like this in my blog last year about using FluorineFx Aperture which works really well.
C++ Plus AIR
March 29th, 2009
Hey Dustin,
Interesting … I’m curious as to how Aperture really works and how it is able to talk between an AIR app and a DLL … is this communication (network or file) socket based? or were they able to exploit some security hole in AIR?
Mrinal
April 3rd, 2009
@FaisalAbid you already can use flash in Titanium – in fact, you can do more with #titanium than you can with #air – see http://is.gd/oy9f
April 3rd, 2009
@mdowney Mike. Steev just gave me some more info on Titanium. It does do flash and stuff air cant do . http://is.gd/oy9f
April 5th, 2009
Titanium. A better option that AIR? Anyone looking at Ttanium? http://tinyurl.com/dkjh2v #air #titanium
April 6th, 2009
Using #titanium to do things #AIR can’t do: http://bit.ly/PApOv
April 6th, 2009
Hii Mrinal !
Its been long time the Titanium PR3 launched . We are waiting for the new application buildup with Titanium and AIR . I hope you will get some free time to show us the power of Titanium .
Thanks & Regards!
! Amar Shukla !
April 6th, 2009
Hi Amar,
Was hoping to do that this weekend … but couldn’t find any free time … will try and package for the new version later tonight
Mrinal
April 14th, 2009
thnx ! I’ll be waiting for the new sample app.
April 21st, 2009
btw mrinal, .app files are really not a single file. They are generally a directory (do a ‘ls -a’ on the command line or else “Finder -> right click -> Show package content”). You will need to zip it before distributing them.
May 6th, 2009
I likes me some Adobe AIR but Titanium makes me drool… http://tr.im/kBOc
June 11th, 2009
@destroytoday @mrinal has a blog on using a ActionScript w/ #titanium http://tr.im/o6OC