2 Replies Latest reply on Feb 22, 2013 8:53 AM by dasdeckone

    binary behaves differently / #include in binary

    dasdeckone

      hi there.

      i wrote a javascript "Application" for indesign.

      now i want to distribute as a binary.

      but it does nit work as expected.

       

      here is the "root" script.

       

      --------------------------------------------

      #targetengine session

       

      #includepath "/Volumes/DC"

       

      #include "javascript/lib/JSON-js/json2.js"

       

      #include "javascript/classes/Iterator.js"

      #include "javascript/classes/Translation.js"

      #include "javascript/InDesign/IDTranslations.jsx"

      #include "javascript/InDesign/IDTools.jsx"

       

      #include "javascript/classes/abstract/ModelObject.js"

       

      #include "javascript/classes/Model.js"

       

      #include "javascript/InDesign/JSONCollector.jsx"

      #include "javascript/InDesign/IDWebSocket.jsx"

      #include "javascript/InDesign/IDServer.jsx"

      #include "javascript/classes/Auth.js"

      #include "javascript/InDesign/IDAuth.jsx"

       

      #include "javascript/InDesign/AdDesigner.jsx"

      #include "javascript/InDesign/PageDesigner.jsx"

       

      CWCore.workingDirectory = new File($.fileName).parent.parent;

       

       

      Auth.init();

       

      myMenu = {

         

      }

       

      CWIDTools = {

          'apps':

              {

              'AdDesigner':new AdDesigner(),

              'PageDesigner':new PageDesigner()

          },

          'buildMenus':function()

          {

              var self = this;

              var menu = this.createMenu( 'CW-Designer' );

              while(menu.menuItems.length > 0)

                  menu.menuItems.lastItem().remove();

                 

              Iterator.each(self.apps,function(k,o)

              {

                  var appName = k;

                 

                  var menuAction = app.scriptMenuActions.add(appName);

                  var listener = menuAction.eventListeners.add( "onInvoke", function()

                  {

                      // this is not executed when loaded as binary!!!!

                      alert(appName);

                      self.apps[appName].init();

                  });

                 

                  var menuItem = menu.menuItems.add( menuAction );

              });

         

          },

          'init':function()

          {

              this.buildMenus();

          },

          'createMenu':function( aTitle ) {

              var aMenu;

          try   

              {

                  aMenu = app.menus.item("$ID/Main").submenus.item( aTitle );

          } 

          catch ( e )    

              {

                  aMenu = app.menus.item("$ID/Main").submenus.add( aTitle );

          }

          return aMenu;

          }

      }

       

      CWIDTools.init();

      --------------------------------------------

       

      i inserted an alert to test the menu item selection.

      in the script version the menu is triggered.

      but in the compiled version it is not..

      can you explain what is different here?

      i suspected it had soemthing to do with includes, but no luck so far.