At the FITC, a couple of days back, Lee Brimlow was talking about the capabilities of AIR and my question was if you can have animated dock icons, answer is yo can ![]()
It works like this; To animate or draw an icon, you take an item loaded externally or that is in your DisplayList or even in the library. You then draw that item with the BitmapData Object to the icons array for the system icon. like this:
var libraryObject = new ClipInLibrary(); var iconBM:BitmapData = new BitmapData(128, 128, true, 0x00000000); iconBM.draw(libraryObject); NativeApplication.nativeApplication.icon.bitmaps = [iconBM];
I wanted to take that to the extreme and see if it was possible to add video to this, so below is the very simple code to draw every frame of a playing video file to a BitmapData Object. I specifically create the bitmap data within the ENTER_FRAME event, so i can dispose of it, and in the next loop create it again. So basicly i draw and clear, draw and clear etc.
The reason why i do this, is that this way you can also have alpha video in your dock
(the example video below uses alpha channels in the video so you can test it!)
Enjoy!
PS. This example is only for Mac, you can do it with Windows, however this icon only supports 16×16 pixels, so the video would be a bit small
import flash.desktop.*;
import flash.events.*;
var videoURL:String = "http://samples.mplayerhq.hu/FLV/flash_with_alpha/300x180-Scr-f8-056alpha.flv";
var con = new NetConnection();
con.connect(null);
var stream:NetStream = new NetStream(con);
var video:Video = new Video();
video.attachNetStream(stream);
stream.play(videoURL);
stream.client = this;
addChild(video);
function createDockIcon(e:Event):void
{
var iconBM:BitmapData = new BitmapData(128, 128, true, 0x00000000);
iconBM.draw(video);
NativeApplication.nativeApplication.icon.bitmaps = [iconBM];
iconData.dispose();
}
this.addEventListener(Event.ENTER_FRAME, createDockIcon);
Thats all there is to it
ADS:
How to rip DVD to iPod MP4 Video? PQ DVD to iPod Video Converter Tutorial. Easy to use, One-click DVD to iPod Converter software for computer Newbie. Rip DVDs to iPod MP4 video. Watch movies on iPod Nano, iPod Touch, iPhone.




on Aug 14th, 2008 at 10:07 am
i am creating a rss application using air, is it possible to get the icon to animate when a variable is true.
on Nov 17th, 2008 at 9:42 pm
Yes you can. You can dynamically set the application icon and draw it on an ENTER_FRAME for instance to animate it.
Sid