这个例子的IconManager封装在了一个SWC里,下面是它的Class源代码: /* Copyright (c) 2008 EverythingFlex.com. http://code.google.com/p/everythingflexairlib/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package { import flash.desktop.NativeApplication; import flash.desktop.NotificationType; import flash.desktop.SystemTrayIcon; import flash.display.Bitmap; import flash.display.BitmapData; import flash.events.TimerEvent; import flash.filters.ColorMatrixFilter; import flash.geom.Point; import flash.geom.Rectangle; import flash.utils.Timer; public class IconManagertest { /** * @private * stores the Array of bitmaps tobe used as icons */ private var sysDockIconBitmaps:Array = new Array(); /** * @private * stores the Array of altered bitmaps tobe used as icons */ private var alteredSysDockIconBitmaps:Array = new Array(); /** * @private * stores the alertType, defaults to NotificationType.CRITICAL */ private var alertType:String = NotificationType.CRITICAL; /** * @private * used as an indicator to determine which state of icon to display */ private var _count:int; /** * @private * timer used to alternate between sysDockIcon and alteredSysDockIcon */ private static var ALERT_TIMER:Timer; /** * Constructor. */ public function IconManagertest(sysDockIconBitmaps:Array, alteredSysDockIconBitmaps:Array=null, alertType:String="critical") { this.sysDockIconBitmaps = sysDockIconBitmaps; this.alteredSysDockIconBitmaps = alteredSysDockIconBitmaps; this.alertType = alertType; handleIcons(); } /** * @private * called by constructor to initialize the icons sets */ private function handleIcons():void{ stopAlert(); if(NativeApplication.supportsDockIcon || NativeApplication.supportsSystemTrayIcon){ if(sysDockIconBitmaps.length > 0){ NativeApplication.nativeApplication.icon.bitmaps = sysDockIconBitmaps; if(alteredSysDockIconBitmaps == null){ alteredSysDockIconBitmaps = new Array(); for (var i:int=0; i 看看这段代码: [Embed(source="assets/Aqua.png")] private var icon1:Class; [Embed(source="assets/alpha.png")] private var icon2:Class; private var _sysTray:SystemTrayIcon; private var _notifyTimer:Timer; //监听图标闪动 private var _state:int=0; //闪动状态 private var _bitmapDataArray:Array = []; //系统任务栏图标数组 /** 设置任务栏监听 **/ private function init(){ _notifyTimer = new Timer(500); _notifyTimer.addEventListener(TimerEvent.TIMER,onNotify); //监听Timer触发有新消息时任务栏闪动事件 /** 设置任务栏图标 **/ initSystenTray(); //初始化任务栏图标 _notifyTimer.start(); } /** * *初始化任务栏图标 * * */ private function initSystenTray():void{ /** 初始化任务栏菜单 **/ var iconMenu:NativeMenu = new NativeMenu(); var showMenuItem:NativeMenuItem = iconMenu.addItem(new NativeMenuItem("显示主窗体")); var settingMenuItem:NativeMenuItem = iconMenu.addItem(new NativeMenuItem("设置...")); iconMenu.addItem(new NativeMenuItem("-", true)); var exitMenuItem:NativeMenuItem = iconMenu.addItem(new NativeMenuItem("退出程序")); exitMenuItem.addEventListener(Event.SELECT, onExitApp); /** 初始化任务栏显示图标 **/ _bitmapDataArray[0] = (new icon1()).bitmapData; _bitmapDataArray[1] = (new icon2()).bitmapData; NativeApplication.nativeApplication.icon.bitmaps = [_bitmapDataArray[0]]; /* *绑定菜单、提示信息 **/ _sysTray = NativeApplication.nativeApplication.icon as SystemTrayIcon; /**.cp 添加任务图标单击事件**/ _sysTray.addEventListener(MouseEvent.CLICK, undock); //任务栏图标点击事件 _sysTray.tooltip = "在线提示"; _sysTray.menu = iconMenu; } /** * *退出系统 * * */ private function onExitApp(evt:Event):void{ NativeApplication.nativeApplication.icon.bitmaps = []; NativeApplication.nativeApplication.exit(); } /** * *每隔500ms触发Timer状态栏闪动提醒事件 * * */ private function onNotify(evt:TimerEvent):void{ if (_state == 0) _state = 1; else _state = 0; NativeApplication.nativeApplication.icon.bitmaps = [_bitmapDataArray[_state]]; } /** * * 系统任务图标点击事件 * * */ /**.cp 有新消息则显示新消息,没有暂不处理**/ public function undock(evt:Event):void { //自己写处理代码 } 来源:http://forum.airia.cn/archiver/FLEX/thread-14645-1.html