4 Replies Latest reply on Oct 30, 2014 7:01 AM by Loic.Aigon

    Including javascript dependencies issues in EB2.1

    Loic.Aigon Adobe Community Professional

      Hi all,

       

      I have an issue with an extension. I am calling a jsx file from an extension*. I do that for a long time ago woithout issues. I now tried to include "jsinc" files in my main jsx file. I set an include path related to a url of mine ( "/Users/… ). I thought EB would del with that and do its own cooking but fact is, it doesn't. When compiled, extension works fine at my place but doesn't in different computers than mine. I suspect the absolute url is the cause of my troubles. But using relative urls don't seem to work neither.

       

      What is the proper way to achieve an inclusion of external js files ?

       

      TIA,

       

      Loic

       

      PS:

       

      Here is my pattern :

       

       

      Using a class declaration :

       

      [ Embed (source="Javascript/JSXAPI.jsx" , mimeType=  "application/octet-stream" )]
      

       

      and then in my jsxfile :

       

      #includepath '/Users/sunsikim/Documents/Scripting/Extensions/ExtensionV2/src/Javascript/'

      #include 'DateUtilities.jsinc';

      #include 'Utils.jsinc';

      #include 'PrefsUtils.jsinc';

       

      //my code…

       

       

       

       

      *using : http://cookbooks.adobe.com/post_Communicating_between_JavaScript_and_the_Creative-17383.ht ml

        • 1. Re: Including javascript dependencies issues in EB2.1
          mlavie Level 1

          Hi Loic,

           

          Did you ever get this solved? How?

           

          Regards,

          mlavie

          • 2. Re: Including javascript dependencies issues in EB2.1
            Loic.Aigon Adobe Community Professional

            Hi MLavie,

             

            Yeah I did it working thanks to Martinho. Fact is you cannot use dependencies with a clear code. You have to compile it in JSXBIN, then eval this code:

             

            Source JSX File

             

            function toto();

             

            Binary

            @2.0UUYAUAYUYZAUYUYUYUYUY…

             

            JSX to call

            eval('@2.0UUYAUAYUYZAUYUYUYUYUY…');

             

            From AS3

            JSX.toto();

             

            I wish we could have keep the whole thing open but nothing to expect now Seems like the HTML5 extensibility will allow this kind of stuff

            • 3. Re: Re: Including javascript dependencies issues in EB2.1
              mlavie Level 1

              Hi Loic,

               

              Thanks for the quick response. However, I don't think I understood the answer. My situation is as follows:

               

              I have an embedded JSX: JSX1.jsx, whose contents are:

               

              function action1()

              {

                  action2();

              }

               

              The definition for action2() is found in JSX file JSX2.jsx, located in the /src dir,  whose contents are:

               

              function action2()

              {

                   alert('I am action2','title',false);

              }

               

              In my ActionScript, I call action1() as follows:

               

                [Embed(source="JSX1.jsx", mimeType= "application/octet-stream" )]
                private static var _jsx1ProxyClass:Class; 
                private static var _jsx1Interface:HostObject;

               

              public function performJsx()
              {
                 _jsx1Interface = HostObject.getRoot(HostObject.extensions[0]);
                 _jsx1Interface.eval(new _jsx1ProxyClass().toString());

                 _jsx1Interface.action1();

              }

               

              Could you please explain step-by-step what to do?

              1. Which of the 2 files (or both) are converted to JSXBIN?
              2. In which folder should they be placed in the ExtensionBuilder project's folder tree? /src? Does it matter?
              3. What changes (if any) need to be made in my ActionScript, JSX1.jsx or JSX2.jsx source code so that my JSX1.jsx "sees" JSX2.jsx?

               

              Thank you for your time!

              mlavie

              • 4. Re: Re: Including javascript dependencies issues in EB2.1
                Loic.Aigon Adobe Community Professional

                Hi MLavie,

                 

                Given your scripts within the src folder :

                 

                Source Main Code : JSX1.jsx

                 

                #include "JSX2.jsx"

                function action1() {

                action2();

                }

                 

                Now you need a third script JSX_BIN.jsx

                but first compile as binary your JSX1.jsx script.

                Once that done copy/paste the jsxbin string

                eval(your JSX1.jsx script as binary goes here);


                Then you embed the JSX_BIN.jsx script.

                [Embed(source="JSX_BIN.jsx", mimeType= "application/octet-stream" )]

                  private static var _jsx1ProxyClass:Class; 

                  private static var _jsx1Interface:HostObject;


                And call it as you did :

                public function performJsx()
                {
                   _jsx1Interface = HostObject.getRoot(HostObject.extensions[0]);
                   _jsx1Interface.eval(new _jsx1ProxyClass().toString());

                   _jsx1Interface.action1();

                }


                And yes, as many changes you do in the source JSX1 file, you need to recompile and copy/paste in the JSX_BIN.jsx script.


                Hope that helps,


                Loic