« Make Text Fade in Flash Without Embedding Fonts | Main | AIR is Desktop 2.0 »
October 10, 2007
Generating Dynamic Dock and System Tray Icons in AIR
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).
AIRPressure works with the publicly available AIR Beta 2. If you want to check it out, click on one of the links below, or click on the install badge at the bottom of the post.
- Download AIRPressure.air (view source enabled).
- Download the source code for AIRPressure (requires as3notificationlib and as3preferencelib).
Posted by cantrell at October 10, 2007 1:11 PM
Comments
Really nice example which comes in handy in many projects. Thanks for sharing this ! :-)
Posted by: Cyril at October 11, 2007 10:18 AM
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.
Posted by: John C. Bland II at October 11, 2007 10:32 AM
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.
Posted by: Jonathan Snook at October 13, 2007 10:55 PM
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!
Posted by: Jonathan Snook at October 14, 2007 9:05 PM
Where do i get the library's mentioned above.
The links send me to google code but the download section is empty!
Posted by: jaxon at October 18, 2007 1:34 AM
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
Posted by: Barna at November 13, 2007 5:13 AM
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
Posted by: Thijs at November 23, 2007 12:07 PM
I tried to use this in my code
but the purr.as failed to import flash.desktop.DockIcon;
flash.desktop.InteractiveIcon;
flash.desktop.SystemTrayIcon;
what could be the problem
I am using
FLEX 3 BETA 2
Posted by: sujon at November 29, 2007 2:53 AM
the libraries are not on Google - your links take me to emptiness..
Are the lib's somewhere on this site or elsewhere ??
Posted by: John Conley at November 30, 2007 7:15 PM
John, all the links are working fine for me. They link directly the projects on Google Code.
Posted by: Christian Cantrell at December 3, 2007 10:45 AM
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
Posted by: Christian Cantrell at December 3, 2007 10:48 AM
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.
Posted by: Andy Matthews at December 4, 2007 6:59 AM
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
Posted by: Sidney de Koning at January 17, 2008 9:23 AM
Hi,
Totally off the wall question: What is the meaning of the name of the Purr class in your awesome as3notificationlib? :)
Posted by: Sunil at August 7, 2008 3:14 PM
Sunil,
When I started the framework, I was planning on building something similar to Growl on OS X -- hence the name Purr. :)
Christian
Posted by: Christian Cantrell at August 8, 2008 2:45 PM