代码如下
private function init(){
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,prepareForSystray);
loader.load(new URLRequest("assets/images/tool16.png"));
this.addEventListener(Event.CLOSING,closeAppHandler);
}
private function closeAppHandler(event:Event):void{
event.preventDefault();
Alert.show("您确定要关闭程序?点击'是'将会退出程序,点击'否'最小化到系统托盘.",'提示',Alert.YES|Alert.NO,this,closeApp);
}
private function closeApp(event:CloseEvent):void{
if(event.detail==Alert.YES){
stage.nativeWindow.close();
}else{
dock();
}
}
public function prepareForSystray(event:Event):void{
dockImage=event.target.content.bitmapData;
if(NativeApplication.supportsSystemTrayIcon){
setSystemTrayProperties();//设置托盘菜单的事件
SystemTrayIcon(NativeApplication.nativeApplication.icon).menu=createSystrayRootMenu();//生成托盘菜单
}
}
本文介绍了一个使用Flash开发的应用程序如何加载图标并设置系统托盘功能的过程,包括加载图片资源、创建托盘图标及菜单,并实现了应用程序关闭时的确认对话框功能。
1697

被折叠的 条评论
为什么被折叠?



