Calendar

November 2008
M T W T F S S
« Oct    
 12
3456789
10111213141516
17181920212223
24252627282930

Tag Cloud

Categories

Archives

Highest Rated

Most Viewed

Recent Posts

Recent Comments

IconManager

By Rich Tretola | September 12, 2008Print This Page Print This Page
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
387 views

Alerting the user with a visual alert of the application icon is common in the world of desktop application but other than the bounce functionality on Mac, it is not currently part of the AIR api. This class will allow you to call an alert method which will cycle through 2 sets of icons which will display a flashing icon to the user.

  1. private var i:IconManager = new IconManager(defaultSysDockIconBitmaps);

Constructor arguments
sysDockIconBitmaps:Array - An array of bitMapData which should represent the 16, 32, 48, and 128 icon sizes. *required
alteredSysDockIconBitmaps:Array - An alternate array of bitMapData which should represent alert set of 16, 32, 48, and 128 icon sizes. If this is not passed in an alternate set will be created by applying a ColorMatrixFilter to the sysDockIconBitmaps.

methods
startAlert(message:String=”",alertType:String=”") - This method starts the icon alert. This method has two optional arguments, the first is a message that will appear as the toolTip of the systemTrayIcon within the Windows environment. The second will define the NotificationType for the icon within the Mac OS. If undefined the default will be to bounce the icon once. If NotificationType.CRITICAL is passed in, the icon will bounce until the user interacts with it.

stopAlert() - will stop an active alert

Sample including only the default set of icons within the IconManager constructor and both optional arguments within the startAlert method. This example is set on a 3 second delay so that if you are on a Mac, you can change focus to a different operating system window before the bounce starts. The bounce will not run if the application is currently the main application in focus.

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
  3.     width="200" height="100">
  4.    
  5.     <mx:Script>
  6.         <![CDATA[
  7.         import com.everythingflex.air.managers.IconManager;
  8.            
  9.         [Embed(source="assets/icons/AIRApp_16.png")]
  10.         private var Icon16:Class;   
  11.         private var bitmap16:Bitmap = new Icon16();
  12.        
  13.         [Embed(source="assets/icons/AIRApp_32.png")]
  14.         private var Icon32:Class;   
  15.         private var bitmap32:Bitmap = new Icon32();
  16.        
  17.         [Embed(source="assets/icons/AIRApp_48.png")]
  18.         private var Icon48:Class;   
  19.         private var bitmap48:Bitmap = new Icon48();
  20.        
  21.         [Embed(source="assets/icons/AIRApp_128.png")]
  22.         private var Icon128:Class
  23.         private var bitmap128:Bitmap = new Icon128();
  24.        
  25.         private var defaultSysDockIconBitmaps:Array = [bitmap16.bitmapData,
  26.                                   bitmap32.bitmapData,
  27.                                   bitmap48.bitmapData,
  28.                                   bitmap128.bitmapData];
  29.        
  30.         private var i:IconManager = new IconManager(defaultSysDockIconBitmaps);
  31.            
  32.         private var timer:Timer;
  33.        
  34.         private function testAlert():void{
  35.             timer = new Timer(3000,1);
  36.             timer.addEventListener(TimerEvent.TIMER_COMPLETE,timerComplete);
  37.             timer.start();
  38.         }
  39.        
  40.         private function timerComplete(event:TimerEvent):void{
  41.             /**
  42.             * set toolTip to 'ALERT! ALERT!' (Windows Only)
  43.             * set NotificationType to CRITICAL (Mac Only)
  44.             */
  45.             i.startAlert('ALERT! ALERT!',NotificationType.CRITICAL);
  46.         }
  47.         ]]>
  48.     </mx:Script>
  49.     <mx:Button click="testAlert()" label="Start Alert"
  50.      horizontalCenter="0" verticalCenter="0"/>
  51. </mx:WindowedApplication>

Share/Save/Bookmark