2 Replies Latest reply on Mar 17, 2013 1:22 PM by JBS001

    Simple createChild script returns undefined error but runs in console?

    JBS001

      Hi,

       

      Okay, I am definitely a newbie...I've read many threads done many searches and no matter what I do I cannot get the following to run successfully within the js file. Even though the code will run in console...

       

      /* Create Bookmark */

      var myRoot=this.bookmarkRoot;

       

      function createBookMark()

      {

       

      myRoot.createChild("testing", 0);

       

      }

       

      app.addToolButton({

         cName: "Add Bookmark Test", //Button name

         cExec: "createBookMark()", //Function call

         cLabel: "Create bookmark test", //The text on the button

         cTooltext: "Create bookmark test" //Help text

      });

       

      Error:

       

      myRoot is undefined

      25:App:Exec

      TypeError: myRoot is undefined

      25:App:Exec

       

      Within console:

       

      var myRoot=this.bookmarkRoot;

      myRoot.createChild("testing", 0);

       

      code runs without error.

       

      What am I doing wrong?