Chapter 12. Application and Window Native Menus

Operating systems provide facilities for creating menus; these menus are called native menus. Adobe AIR supports working with native menus, and the recipes in this chapter show you how to build several types of native menus. At this writing, AIR supports application, window, context, and pop-up menus. Application and window menus serve the same purpose but on different platforms. Specifically, window menus are available only on Windows, and application menus are available only on Macs. Computer users are familiar with the typical native menus, so the usability of your AIR application improves a lot when you offer users application or window menus.

To create native menus, the Adobe AIR classes to use are flash.display.NativeMenu and flash.display.NativeMenuItem.

To create context menus, you can also use the classes flash.ui.ContextMenu and flash.ui.ContextMenuItem.


AIR enables you to create system tray and Dock icon menus as well. See Chapter 13 for more information on these custom taskbar and Dock menus.

Creating a Native Menu


You want to create a menu for your AIR application and present the menu as an application menu or window menu depending on the user’s operating system.


Use the NativeMenu constructor to create the base menu, attach child NativeMenuItem objects, and then set the top-level base menu as the menu for the AIR application or window depending on your preference or the operating system.


When working ...

Get Adobe AIR 1.5 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.