I have dabbled a bit in AIR for sometime and really love the ability to make an “official” feeling app for Windows while working in flash. How much more official can you get than altering the NativeMenu of the window with whatever you want (rendered in text that is). You are at the mercy of the OS, but still, I can even place line separators if I want! Read on for the code…

I had a hard time finding a simple intro to using the NativeMenu, so here is some code for a basic Hello World NativeMenu demo.

import flash.display.*;
import flash.desktop.*;
 
stage.nativeWindow.menu = new NativeMenu();
 
var menuItem:NativeMenuItem = new NativeMenuItem("Hello!");
 
var subMenu:NativeMenu = new NativeMenu();
var btn1:NativeMenuItem = new NativeMenuItem("World");
btn1.addEventListener(Event.SELECT, itemClicked);
subMenu.addItem(btn1);
menuItem.submenu = subMenu;
 
stage.nativeWindow.menu.addItem(menuItem);
 
function itemClicked(e) {
   trace("You Selected: ", e.target);
}

Source

  • Digg
  • Reddit
  • del.icio.us
  • Facebook
  • Technorati
Email This Post Email This Post

Leave a Reply