Transfer to Region Program You can add a system tray icon for it.
Online Article Many, here is a brief description, and lists the steps and key Code
Brief Description
1. operations on the tray icon are related to the nativeapplication. Icon attribute of the current air application, such as bitmaps and menu attribute.
2. For Windows and Mac systems, the instance objects of nativeapplication. Icon are different.Systemtrayicon object, while Mac (Apple system) returns
Dockicon object
(Windows is used as an example)
3. to add the icon to the system tray, you only need to set the nativeapplication of the current air application. icon. bitmaps properties, you can see the icon in the system tray, but there is no event response, you need to further process
4. Add the left-click event of the system tray. In this case, the window is usually restored to the normal state.
Add a mouseevent. Click Event to systemtrayicon
5. Right-click the system tray icon to add a menu list, such as opening or exiting.
You need to set the menu attribute of systemtrayicon.
6. nativewindow. Visible controls the icon of the air application on the taskbar (not the system tray ).
To add a system tray icon
1. Add the system tray icon when minimizing the event. You can directly add it to the Click Event of a button for testing.
// Minimize to System Tray Processing
Private function dockhandler (): void {
This. nativewindow. Visible = false;
// Add the taskbar icon
Addmediarayicon ();
}
[Embed (Source = 'Assets/airapp_16.png ')]
Private var icon16: class;
Private function addmediarayicon (): void {
//
Icon16 is an image file with a size of 16*16.
This. nativeapplication. Icon. bitmaps = [New icon16 ()];
If (nativeapplication. supportssystemtrayicon ){
VaR STI: systemtrayicon = systemtrayicon (this. nativeapplication. Icon );
// Create a menu list
STI. Menu = createsystraymenu ();
// Restore the window when you click the system tray icon
STI. addeventlistener (mouseevent. Click, restorefrompolicrayhandler );
}
}
2. Create a context menu for the system tray icon
Private function createsystraymenu (): nativemenu {
VaR menu: nativemenu = new nativemenu ();
VaR labels: array = ["open", "", "Exit program"];
VaR names: array = ["mnuopen", "mnusep1", "mnuexit"];
For (var I: Int = 0; I <labels. length; I ++ ){
// If the tag is empty, it is considered as a separator.
VaR menuitem: nativemenuitem = new nativemenuitem (labels [I], labels [I] = "");
Menuitem. Name = Names [I];
Menuitem. addeventlistener (event. Select, systraymenuhandler); // The Menu handles the event.
Menu. additem (menuitem );
}
Return menu;
}
3. Add a system tray menu event and process it according to the menu name.
Private function extends raymenuhandler (Event: Event): void {
Switch(event.tar get. Name ){
Case "mnuopen": // open the menu
Undockhandler ();
Break;
Case "mnuexit": // exit the menu
Exithandler ();
Break;
}
}
4. Restore from the system tray to the taskbar
Private function undockhandler (): void {
This. nativewindow. Visible = true;
This. nativeapplication. Icon. bitmaps = [];
// The Front mentioned in the window
This. nativewindow. ordertofront ();
// Activate the current window
This. Activate ();
}
5. Menu events for exiting the program
Private function exithandler (): void {
This. Exit ();
}
The above are some of the key points for adding the air icon for your reference only.