by Christian Cantrell

 Comments (19)

Created

October 10, 2007

Update (11/18/09): AIRPressure has been renamed to Timeslide. All links below have been update.

Someone asked me the other day if AIR applications can generate dynamic dock and system tray icons. The use case is something like Mail.app on Mac which always shows you the number of unread messages as part of the dock icon.

I’m happy to report that this is perfectly possible in AIR, and I created a sample application called AIRPressure to demonstrate. AIRPressure is a countdown timer which shows a dynamically generated timer icon in your dock or system tray to let you know how much time is left. It also has some other cool features:

  • It will optionally show a notification window when the timer is complete.
  • It will optionally open a URL in your browser when the timer is complete.
  • The dock icon bounces or the task bar icon flashes when the timer is complete.
  • All your settings are saved between uses.

The code for AIRPressure is probably more interesting than the application itself. For notifications (notification windows, bouncing the dock icon, flashing the task bar entry), and for changing the dock and system tray icons in a cross-platform manner, I use the as3notificationlib project that my team has been working on which makes it extremely simple. And for persisting preferences, I use the new as3preferencelib that my team also wrote which handles all file IO, encryption, and serialization automatically. AIRPressure is a pretty useful and comprehensive cross-platform application, and the entire app is only about 300 lines of code (thanks to all these libraries doing a lot of the heavy lifting).

COMMENTS

  • By Cyril - 10:18 AM on October 11, 2007   Reply

    Really nice example which comes in handy in many projects. Thanks for sharing this ! :-)

  • By John C. Bland II - 10:32 AM on October 11, 2007   Reply

    Nice Christian! I wish there was a way to easily add text over the icon without having to draw it. This is pretty cool though.

  • By Jonathan Snook - 10:55 PM on October 13, 2007   Reply

    For those of us developing AIR apps using HTML/JS and don’t have Flash, can you create a compiled SWF of the two libs you’ve mentioned, as3notificationlib and as3preferencelib. Specically, I’d like to integrate the notification library into an app to make it easier to do notifications. It’d be nice to see app developers circle around a single implementation of something like this to make all AIR apps more consistent in their behaviour.

  • By Jonathan Snook - 9:05 PM on October 14, 2007   Reply

    I ended up downloading a trial version of Flash CS3 and after a few hours of trying to figure out how it all works, I compiled the notification lib into a SWF that I could use in my HTML project. Thanks a bunch!

  • By jaxon - 1:34 AM on October 18, 2007   Reply

    Where do i get the library’s mentioned above.The links send me to google code but the download section is empty!

  • By Barna - 5:13 AM on November 13, 2007   Reply

    Really nice work, am developing an air app as well right now, that’s how I found it. I had some problems regarding to dock icons’ bouncing in Leopard 10.5 (couldn’t get ‘em bounce at all, wia no notification type)… I installed your app, the native windows worked properly, the icon changed, but no bouncing… Have you tested it on such OS? Am I doing sg. wrong, or is this a bug in AIR beta 2? If you come across sg. please drop me a line! Thanx for your time! Best regards: Barna

  • By Thijs - 12:07 PM on November 23, 2007   Reply

    Nice library, worked great on OSX 10.4.@jaxon: you need to download the code from the Subversion repository, looks like there’s no zip available.@jonathan snook: you can also use the free, soon to be open source, Flex SDK to compile the notification lib into a SWF

  • By sujon - 2:53 AM on November 29, 2007   Reply

    I tried to use this in my codebut the purr.as failed to import flash.desktop.DockIcon;flash.desktop.InteractiveIcon;flash.desktop.SystemTrayIcon;what could be the problemI am usingFLEX 3 BETA 2

  • By John Conley - 7:15 PM on November 30, 2007   Reply

    the libraries are not on Google – your links take me to emptiness..Are the lib’s somewhere on this site or elsewhere ??

  • By Christian Cantrell - 10:45 AM on December 3, 2007   Reply

    John, all the links are working fine for me. They link directly the projects on Google Code.

  • By Christian Cantrell - 10:48 AM on December 3, 2007   Reply

    sujon,All these libraries have been updated for beta 3 which will be available shortly. They are no longer compatible with beta 2. Sorry about that.Christian

  • By Andy Matthews - 6:59 AM on December 4, 2007   Reply

    How difficult is it to remove the setInterval on the alert fadeout? For example, if you wanted the message to stay up until the user explicitly closed it.

  • By Sidney de Koning - 9:23 AM on January 17, 2008   Reply

    Hi Christian,i grabbed the latest version from the svn, whoever, you said that they are updated for beta3 but i get a RTE on Shell.shell. Can you tell me how to update this?Thanks,Sidney

  • By Sunil - 3:14 PM on August 7, 2008   Reply

    Hi,Totally off the wall question: What is the meaning of the name of the Purr class in your awesome as3notificationlib? :)

  • By Christian Cantrell - 2:45 PM on August 8, 2008   Reply

    Sunil,When I started the framework, I was planning on building something similar to Growl on OS X — hence the name Purr. :) Christian

  • By Paul Haddon - 9:35 PM on November 16, 2009   Reply

    Neither the .air nor .zip files are currently available.Both return 404 error page notices.

  • By Christian Cantrell - 9:11 AM on November 19, 2009   Reply

    @Paul: Thanks for the heads-up. These files didn’t get moved the last time my blog was migrated. I just updated the links.

  • By antonio brandao - 3:44 PM on December 22, 2010   Reply

    the source code link is down :(

  • By Christian Cantrell - 5:27 PM on December 22, 2010   Reply

    Sheesh. Updated the link again. Sorry about that.

ADD A COMMENT