5 Flash applications that will blow your mind

Yell.com Maps
“A 3D map? We’ve seen that before!” Trust me… This is 3D mapping like you’ve never seen before! It’s hard to explain when you look at this static image so just check it out yourself! Hat tip to Jerome who posted this in a comment on my blog.

UJam
I already blogged about UJam earlier but they’ve […]

Fun with AIR on Android – Geolocation

There are a lot of things that make building apps for mobile devices extremely fun and addictive.  I’ve especially had fun with the onboard GPS in my Google Nexus One using ActionScript (flash.sensors.Geolocation class).  It’s actually very simple.  Here’s a trivial example: if(Geolocation.isSupported) { geo = new Geolocation(); geo.addEventListener(GeolocationEvent.UPDATE,geoUpdate); geo.setRequestedUpdateInterval(10000); // update my location every […]

Get started with AIR on Android before you get an Android device!

Recently, Adobe announced the public beta of AIR on Android.  This excitement combined with all of the energy from the recent Google IO conference has a lot of developers wanting to dig right in!  If you don’t have access to an Android device today, don’t let that stop you from having some fun.  The Android […]

Android week: On switching to Android

When I first saw the iPhone I immediately fell in love with it. After walking around with an iPod, a PDA and a mobile phone I could finally have all of these things in one device. I was worried that when I switched to Android I would need to go back to using 2 devices […]

Package Assistant Pro

A few months ago I released an early version of my Package Assistant application. The application made it easier to compile native installers for AIR 2. While it was a lot easier to use compared to using the command line the application wasn’t very user friendly. A few weeks ago I started working on a […]

AIR2.0 RC available on Labs

The Adobe AIR 2 Release Candidate (RC) build is now available on Adobe Labs. Please be sure to download the latest AIR runtime and, if you are an application developer, SDK. If you run into any issues, please let us know by using our feedback form to send us a bug. Please be sure to include all relevant […]

Scaling an Adobe AIR application to fit multiple resolutions and Netbooks

A few months ago, I blogged about a little side project I’m involved in called ChessJam, an online live chess application built with Flex that runs as a desktop application on Adobe AIR.  A few weeks ago, we had some users complain that ChessJam was basically unusable on Netbooks.  Further investigation confirmed that we had […]

Hands-On Review of Android Multi-touch Tablet

At Web 2.0 Expo this year in the Adobe booth we’re showing off some devices and tablets running Android with full Flash Player and AIR on them.

It runs Adobe’s Flash and Air apps flawlessly. That was the first time I saw Adobe’s Air apps running on a tablet and totally impressed by how it ran. And now I can understand why Apple wants to ban Flash and other Adobe products completely from their iPhones and iPads, because it’s rather incredible technology.

It’s been a bit of a long haul, but we’re really close to putting the runtimes in you guys’ hands so you can see it for yourself.

Using NativeProcess in AIR 2 with GPSBabel

GPSBabel is one of the coolest projects on the internet. It takes basically any geolocation format and quickly lets you convert it into any other format. And the world of geodata is a wild west of various formats so it makes it super easy to bring all of that together in a handy command line tool.

Because it has a command line tool I figured it would make a pretty good (and easy) demo for AIR 2’s NativeProcess APIs. And it does! In fact, I started work on an ActionScript 3 wrapper that (should) make it easy to call GPSBabel from an AIR application and make it do your bidding. It’s in really, really rough shape, but here’s the beginning of it.

Getting Started

The first thing you need to do to use the NativeProcess API is to alter your app-xml file. After the initialWindow tag are a bunch of commented lines that talk about supportedProfiles. The NativeProcess API only works in the extendedDesktop profile so you need to enable it with this line.

<supportedProfiles>extendedDesktop</supportedProfiles>

With that, you can start testing the NativeProcess API.

Calling GPSBabel

Using the NativeProcess API is pretty simple. You first create a NativeProcessStartupInfo object which is where you point to the executable binary as well as pass in any arguments. Then you set up event listeners on the NativeProcess object, and finally you call the start() method and pass in your startup object.

To convert one file type from another, GPSBabel takes a series of command line arguments. This is the command to convert a GPX file into a KML file.

gpsbabel -i gpx -f /tmp/myroute.gpx -o kml -F /tmp/myroute.kml

So to replicate this with the NativeProcess API first create the startup object and pass in those arguments. The -i is the format of the original file, -f points to the original file, -o is the format to convert to, and -F is the converted file. All of those are pushed to the arguments property of the startup object.

var npsi:NativeProcessStartupInfo = new NativeProcessStartupInfo();
// The location of GPSBabel (a file object)
npsi.executable = _gpsBabelLocation;
var args:Vector.<String> = new Vector.<String>;
args.push("-i");
args.push("gpx");
args.push("-f");
args.push("/tmp/myroute.gpx");
args.push("-o");
args.push("kml");
args.push("-F");
args.push("/tmp/myroute.kml");
npsi.arguments = args;

The next step is to add event listeners to the NativeProcess object. Most of the time, GPSBabel just sends standard messages in UTF, so handling responses is easy. In the case of a conversion, the only event listener that really matters is the error listener.

_process = new NativeProcess();
_process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA,onStandardErrorData);

Dealing with NativeProcess events was a little odd to me, but because GPSBabel just returns text, this is pretty easy. If it errors, out, it dumps text to the screen. That text becomes part of the NativeProcess object. Depending on what the context is (if it’s an error, or just regular data output) it goes into a different variable. In this case, the event listener just reads the error data from the standardError property and traces it out

private function onStandardErrorData(event:ProgressEvent):void
{
trace(_process.standardError.readUTFBytes(_process.standardError.bytesAvailable));
}

The last thing to do is to go back up and start the process off by calling the start method and passing in the startup options that were created before.

_process.start(npStartupInfo);

And that’s it. I’ve got an example on GitHub as part of the GPSBabelOnAIR project. The mxml file in the examples folder uses the library which is where all of the NativeProcess code in. The combination of those should provide a working basic example of using NativeProcess and GPSBabel.