Tag Archives: code

Using Growl in AIR applications with AIR 2 NativeProcess

The AIR2 release is just around the corner and one of my favorite new features is the ability to use native scripts. As I’ve already demonstrated earlier, this is extremely powerful and here’s another good example.

From the moment AIR was released, a lot of developers were asking for Growl support to add toast style notifications. Up until now, there hasn’t really been an easy and flexible solution so most developers opted to build their own notifications. I really like Growl and the fact that you as a user have total control over the look and feel. I use the Mono style created by Christopher Lobay. It’s probably the sexiest toast style notification I’ve ever used.

With AIR 2 you can now call Growl right from within your application. I actually call the Growlnotify command-line tool, which comes as an extra in the Growl download. Most people probably don’t install these extras but that’s no problem. I can bundle the command-line tool as part of my application and call it directly from my applicationDirectory.

So… How does this work? It’s actually extremely easy… The first thing you do is set up a new File object that points to the Growlnotify tool.

var file:File = File.applicationDirectory;
file = file.resolvePath("growlnotify");

As I am going to bundle growlnotify with my application it will just be installed as part of the app and thus resides in applicationDirectory.

The next thing I have to do is set up a NativeProcessStartupInfo object. That’s where I’ll store the basic information that is used to start our NativeProcess.

var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var processArgs:Vector.<String> = new Vector.<String>();
processArgs[0] = "-n";
processArgs[1] = "My AIR application";
processArgs[2] = "-p";
processArgs[3] = "0";
processArgs[4] = "-t";
processArgs[5] = "Your Growl title";
processArgs[6] = "-m";
processArgs[7] = "Your Growl message";
processArgs[8] = "-a";
processArgs[9] = "Adobe AIR Application Installer";
nativeProcessStartupInfo.arguments = processArgs;
nativeProcessStartupInfo.executable = file;

In this case, I’m also adding a bunch of arguments in my NativeProcessStartupInfo object. These arguments will be passed on to the growlnotify command-line tool. In this example, I’m setting up the name of my application, the notification priority, the title and message of my notification and I’m also telling it to use the icon associated with the Adobe AIR Application Installer. (Check out the Growlnotify docs for more info on these settings)

Next and last step is to actually call the native script.

process = new NativeProcess();
process.start(nativeProcessStartupInfo);

This code above will result in this Growl notification:

The only downside of using native scripts is that you’ll have to package your application specifically for the operating system you wrote your native script for. So in this case, I’d have to package it as a .DMG file since Growl only exists on OS X. That said, I really wouldn’t mind an OS X version of TweetDeck that allows me to use Growl instead of their custom notifications…

I really can’t wait to see what you guys are going to build with AIR 2! You can already start today! Check out Adobe Labs for more information!

Read full storyComments { 50 }

Meet the downloadable evangelist

Have you ever wished you had an evangelist by your side every day? Oh… Really? Now that’s just weird ;-) But seriously, it’s always a good thing to be able to tap in to someone’s brain when you get stuck on something or forgot about a component’s capabilities and properties. Or maybe you just want to browse the Flex component library to get an idea of its power and possibilities.

Enter the downloadable evangelist Tour de Flex, a really cool AIR application that showcases core Flex components, AIR capabilities, Flex data access (BlazeDS and LiveCycle Data Services), numerous coding techniques, cloud APIs, and a growing list of community-developed components, effects, skins, and more. There are currently 217 code samples in the application but since this is an AIR application, it’s obvious that we will be updating that with new samples on a regular basis.

Tour De Flex also comes with an Eclipse plugin that allows the various samples to be searched directly from an Eclipse view window.

If you are at MAX, come and find one of us (we’re wearing a Tour de Flex shirt today) to get one of the Tour De Flex USB sticks or go ahead and download it from http://flex.org/tour.

Kudos to Greg Wilson, Christophe Coenraets and James Ward who started this idea.

Read full storyComments { 7 }

Signing AIR applications

My presentation at the On AIR tour through Europe was about signing, deploying and updating your AIR applications. If you didn’t make it to the tour or just want to read up on these topics, I wrote three separate posts about them on the train somewhere between Prague and Munich.

First of all, why is signing an application important? Easy. When your application is unsigned or signed with a self-signed certificate, the user will get two red icons on the install screen. The first one is related to your code signing certificate. It’s telling you that the “publisher is unknown” which is very normal since we have no idea who actually signed this application.

When you do get a code signing certificate and sign the application with it, the icon will turn green or in some cases yellow. The yellow icon will appear when you are using the file I/O API.

(more…)

Read full storyComments { 0 }

Get a complimentary code signing certificate

If you’ve already published an AIR application, chances are you did that by using a self signed code certificate. When you installed the app, the AIR installer told you that the publisher’s identity is unknown.

If you get a code signing certificate from a company like Thawte.com and use that to sign your application, it’s obvious that your identity has been verified. The AIR installer will show that your identity is known.

If you upload your application to the Adobe AIR Marketplace now, you are eligible to receive one Thawte code signing certificate (1 year Class 3 code signing certificate) from Adobe. As this is purely available on a first-come, first-served basis and supplies are limited, you might not want to wait too long to upload your app.

Read details here and then go upload your app on the Adobe AIR Marketplace

Read full storyComments { 6 }

Play video in your dock with AIR

dockvideo screenshotA while back I was thinking if it would be possible to play video in the dock icon with AIR. Then I heard Lee Brimelow ask the same question during his FITC Amsterdam presentation. Last week I had a free moment during the Zurich AIR camp to give it a try and yes… it does work.

First of all let’s think about use-cases for this. Imagine having a video player and when you minimize the app, you can continue watching your video in the dock. Obviously, this will still use the resources needed to actually play the video but I think it’s really cool and wouldn’t actually mind seeing this in an application like the Adobe Media Player. You could even have the user set this option in a prefs panel etc… (more…)

Read full storyComments { 4 }