1 Reply Latest reply on Jan 19, 2009 7:49 AM by iqdev

    OS X Native Application Menu initialization

      This simple native application menu on OS X sometimes work and sometimes doesn't, both within ADL and as a standalone AIR application. At startup time, it appears that the event handler is not always properly installed. When it is, selecting the File->Open menu item will always call the handler. When it is not, the handler will never be called though the menu item exists and can be selected. A single SWF file generated by the compiler can yield both behaviors.

      Are there potential race conditions at startup I need to be aware of?
      Does native application menu manipulation need to done elsewhere?

      I'm using the build of the SDK on OS X 10.5.4.

      Compilation command:
      /Users/XXXX/flex/sdk/ +configname=air toto.as
      Loading configuration file /Users/XXXX/flex/sdk/
      /Users/XXXX/flex/toto/toto.swf (927 bytes)

      AS3 code:
      package {
      import flash.desktop.NativeApplication;
      import flash.display.NativeWindow;
      import flash.display.NativeMenu;
      import flash.display.NativeMenuItem;
      import flash.display.Sprite;
      import flash.events.Event;

      public class toto extends Sprite
      public function toto()
      addEventListener(Event.ADDED_TO_STAGE, display);

      private function display(event:Event):void
      var win:NativeWindow = stage.nativeWindow;

      win.height = 200;
      win.width = 200;
      win.visible = true;

      private function init():void
      var root:NativeMenu;
      var file:NativeMenuItem;
      var open:NativeMenuItem;


      if (NativeApplication.supportsMenu) {
      root = NativeApplication.nativeApplication.menu;

      file = root.getItemAt(1);
      open = file.submenu.addItem(new NativeMenuItem("Open"));
      open.addEventListener(Event.SELECT, fileOpen);

      private function fileOpen(event:Event):void
      trace("file open");

      App description:
      <?xml version="1.0" encoding="UTF-8"?>
      <application xmlns=" http://ns.adobe.com/air/application/1.0">