15 Replies Latest reply on Apr 20, 2011 4:42 PM by Loic.Aigon

    Embedded jsx and includes

    Loic.Aigon Adobe Community Professional

      Hi all,

       

      Is it possible to eval embedded jsx when these files have include calls ?

       

      I mean, let's say extension embed file1.jsx and utilities.jsx. file1.jsx has a #include "utilities.jsx" declaration.

      Right now, it seems to fail, is it a workaround ?

       

      TIA Loic

        • 1. Re: Embedded jsx and includes
          Loic.Aigon Adobe Community Professional

          Sorry for the mess,

           

          It is not working after all

          • 2. Re: Embedded jsx and includes
            Dirk Becker  Level 4

            For performance reasons I just reworked a CS4 PatchPanel project to not embed the .jsx files.

            Instead I use a permanent target engine where the code is installed on startup.

             

            Dirk

            1 person found this helpful
            • 3. Re: Embedded jsx and includes
              Loic.Aigon Adobe Community Professional

              Hi Dirk and thanks a lot for the heads up,

               

              You may be right. But now it's too far advanced to go back . However, I noticed tou can make several classes from embedded files and eval them in a same function. At last, it looks like it works like an include althought, it's a bit scary.

               

              Other point is the CSSDK API Documentation, I just spent an hour trying to get the extension swfPath but with no success

               

              swfPathproperty
              public var swfPath:String

              The path of the compiled Flash (SWF) file that implements this extension

               

              http://cssdk.host.adobe.com/sdk/1.0/docs/WebHelp/references/csxslib/com/adobe/csxs/types/E xtension.html#swfPath

               

              But public var swfPath:String = com.adobe.csxs.types.extension.swfPath looks helpless and I tried dozens of expressions (extensions[0]...)

              Damned AS3 :\

               

               

              Loic

               

              • 4. Re: Embedded jsx and includes
                Bob Stucky Adobe Employee

                          public static function swfPath(): String
                          {
                               return CSXSInterface.instance.getSystemPath( SystemPath.APPLICATION ).data;
                          }
                
                

                 

                That'll get you the path to the extension's swf.

                • 5. Re: Embedded jsx and includes
                  Bob Stucky Adobe Employee

                  I've never tried using an include statement for an embedded jsx. I would think it would not work, though. You could load a simple jsx with a "load" function that uses evalFile() to load your includes and the main script.

                   

                  Frankly, I never used the include statement. It was always easier for me to write a loader function given that when loaded via evalFile, the debugger works on a file by file basis. With jsx includes, the code is piled together making debugging more difficult.

                   

                  Why not port it all to AS3? Performance is way better (the AS part, performance on DOM calls is virtually identical). Code completion avoids so many of those jsx typo errors. I ported my libs to AS3, didn't take that long. And I am certainly noticing the productivity benefit.

                   

                  Regards

                  1 person found this helpful
                  • 6. Re: Embedded jsx and includes
                    Loic.Aigon Adobe Community Professional

                    Hi Dirk, Bob,

                     

                    @Dirk, thanks a lot for the swfPath function, I saw SystemPath.APPLICATION but was convinced it would send me back Indesign application folder instead of the extension folder. Thanks a lot that helps.

                     

                    @Bob, @Dirk,


                    Youy are probably right. It's more about customer developpement history. A lot of jsx files were written in a scriptUI environment. Now we are switching towards an extension, the idea was to stick to jsx files as long as it was possible to reduce porting efforts. These files are related through a lot of includes statements, taht's why I asked at the first place.


                    Also, customer liked extension as they can deliver a plugin like experience, with only one global file hosting everything needed. However, I am quite being desilusionned because I am not certain how far I can go with embedding files. In another topic I asked if it was possible to include exe, sh and bat files in a swf extension as the customer uses the jetS3t library and several files to upload datas onto amazon s3. But I am afraid I can't include the exe (PRPost.exe) and yet run it from inside the swf. So I was looking to put all the uploading classes outside teh extension. hence my need for the swfPath.

                     

                    Sorry for that long explanation, but I wanted to give you the whole picture in case you could share thoughts.

                     

                    Thanks for your valuable inputs

                     

                    Loic

                    • 7. Re: Embedded jsx and includes
                      Bob Stucky Adobe Employee

                      You should be able to do that.

                       

                       

                      Place your assets (the exe, bat, whatever) in a folder off source:

                       

                      src/assets/mybat.bat

                       

                      The "assets" folder will be copied to the folder containing the swf.

                       

                      A file pointing to the bat file would be:

                       

                      new File( swfPath() + "/assets/mybat.bat" ).nativePath;

                       

                       

                      And then you would use NativeProcess to execute/control execution.

                       

                      Regards

                      • 8. Re: Embedded jsx and includes
                        Loic.Aigon Adobe Community Professional

                        Hi Bob,

                         

                        Thanks a lot, it sounds great. As it is stuff I am not used to, could me tell me if I got you right.

                         

                        In my flex project, I create a src/assets/ folder where I put all the utilities files in it. (Then using it in my AS3 code ok)

                         

                        When you say The "assets" folder will be copied to the folder containing the swf. Is it me having to manually copied it next to swf or flex will do ?

                         

                        Last point, I am trying to set native process but it looks like only the Flex 4.1 sdk has the NativeProcess classes. ExtensionBuilder SDK 3.4 generates compile errors.

                         

                        Thanks a lot for all,

                         

                        Loic

                        • 9. Re: Embedded jsx and includes
                          Bob Stucky Adobe Employee

                          Flex will copy the assets across for you.

                           

                          As for NativeProcess, it's in flash.desktop, and is "Air only". The SDK does give you access to Air only classes.

                           

                          Are you using Extension Builder or the CS SDK without ExtensionBuilder?

                          • 10. Re: Embedded jsx and includes
                            Loic.Aigon Adobe Community Professional

                            Hi Bob,

                             

                            I am using flash Builder with ExtensionBuilder SDK. I just succeed in overlaying the sdk with air 2.0 sdk. So now I have access to NativeProcess.

                            I am trying to make it running now (with pain)

                             

                            private function debug():void{
                                                var exeFile:File = new File( swfPath() + "/Assets/test/test.bat" );
                                                var np:NativeProcess = new NativeProcess();
                                                var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
                                                nativeProcessStartupInfo.executable = exeFile;
                                                
                                                np.start(nativeProcessStartupInfo);
                                                alert("done");
                                           }
                                           
                                           public static function swfPath(): String
                                                
                                           {
                                                
                                                return CSXSInterface.instance.getSystemPath( SystemPath.APPLICATION ).data;
                                                
                                           }
                            

                             

                            For now I just copy the swf into Indesign Panels Folder for quick debug. But it's not working. Do I do something wrong ?

                            The test.bat is a dummy bat file that should launch explorer and displays a web page, but it doesn't.

                             

                            Thanks in advance fror your hints, I really need to get it working

                             

                            Loic

                             

                            PS: alert() is of course a tweaked AS3 function.

                            • 11. Re: Embedded jsx and includes
                              Bob Stucky Adobe Employee

                              Forgive me if I'm wrong, Loic; but, you sound a bit frustrated with CS SDK/Extension Builder development.

                               

                              ExtensionBuilder makes my development at least 30% more efficient (or more, depending on the project) compared with ExtendScript. I would have given anything to have ExtensionBuilder for some of my larger projects before I joined Adobe.

                               

                              Anytime you're feeling frustrated with the tooling - post a question here. Someone will answer it!! Yes, ActionScript programming is different from ExtendScript; but, it won't take you all that long to master it and the environment. Once you do that, you'll never turn back.

                               

                              Now - Re-reading your earlier post - you're going through this exercise to talk wiht Amazon's cloud, correct? Depending on how comfortable you are with web service development, you may find it vastly easier to use Flash's web service support. There are a ton of tutorials on the web showing how to do that.

                               

                              As for debugging, here's how to do it:

                               

                              Right click on your project in Flex Builder

                               

                              You should see: Run As, Debug As, and Attach As. Each of those will show the available Host applications. In Debug As, the choices will be the host apps you selected when creating or updating the project (see the projects Properties, CS Extension Builder tab). For Attach As, the available choices will be the host apps you chose that are currently running.

                               

                              The advantage of Attach As is that you can attach to a debug process without having to restart the host application. This is a beta feature and only works with InDesign and Illustrator.

                               

                              Only debug via the Debug As and Attach As menus.

                               

                              I've never attempted to debug by copying the swf to the panels folder. I'm surprised that you can do that!

                               

                              Also - with AS3 "trace" is your friend. Use it A LOT!

                               

                               

                              private function debug(): void {
                                   var exeFile: File = new File( swfPath() + "/Assets/test/test.bat" );
                                   if ( !exeFile.exists ) {
                                        trace( "exeFile does not exist" );
                                        return;
                                   }
                                   var np: NativeProcess = new NativeProcess();
                                   var npi: NativeProcessStartupInfo = new NativeProcessStartupInfo();
                                   var npi.executable = exeFile;
                                   np.start( npi );
                                   trace( "Done" );
                              }
                              

                               

                              Note that NativeProcess does support some level of bi-directional communication with the launched application via the standardError, standardInput, and standardOutput properties.

                               

                              As for the function above, I didn't do any checking, simply typed away - don't just copy / paste it!

                               

                              Regards

                               

                              Bob

                              • 12. Re: Embedded jsx and includes
                                Bob Stucky Adobe Employee

                                I did a google search on "Amazon Web Services ActionScript". Lots of valuable hits.

                                 

                                Here are a couple of links to open source amazon AS3 libraries:

                                 

                                http://www.mikechambers.com/blog/2007/05/30/open-source-amazon-s3-actionscript-library/

                                 

                                http://life.neophi.com/danielr/2008/10/amazon_web_services_aws_for_ac.html

                                 

                                Regards

                                • 13. Re: Embedded jsx and includes
                                  Loic.Aigon Adobe Community Professional

                                  Hi Bob,

                                   

                                  Thanks for your words. Harbs also push me (he is right to do so) to get ExtensionBuilder but as I am not the one in charge of the finances, I just can wait and hope till teh day ExtensioNBuilder comes into my life. A friend of mine tried to make me enter in the prerelease program but I haven't received the invitation yet (it kills me).

                                  So now I have to play with FlashBuilder, implements sdks and etc. with lots of steps in the darkness. It's fun but yes painfull. I am not frustrated by the tools however but by the sensation to walk through a dark fog . I advance very very slowly and it kills me. What enjoys me is the idea I get more and more cumfortable with all these new toys But it doesn't look like I get acess to the "debug as" commands in flashbuilder or at least right click doesn't propose them.

                                   

                                  Let's back to business. Yes the ambition is to communicate with amazon. I saw and offered to play with as3 libraries for amazon, but customer wants to keep with jets3t libraries which from its point of view allow more control over uploading files. In order to look clearer, customer wishes to avoid a lot of extra files like it is right now with extendscript. That's teh point of "embedding" all the stuff".

                                   

                                  As for the code, it looks like everything is well understood except for the start command. I placed an alert after the start command and it never shows up.

                                   

                                  Raaaaa, so close so far.

                                   

                                  Thanks a lot anyway for your really great help here

                                   

                                  Loic

                                  • 14. Re: Embedded jsx and includes
                                    Dirk Becker  Level 4

                                    > why not port it all to AS3

                                     

                                    Bob,

                                     

                                    last time I checked, that was no option for InDesign Server - be it CS4 (our current main workhorse) or later.

                                    Although we have a large part of our code base shared with the client side (maybe 50 of 200 includes) the majority is still server code.

                                     

                                    Dirk

                                    • 15. Re: Embedded jsx and includes
                                      Loic.Aigon Adobe Community Professional

                                      Hi Bob, Dirk,

                                       

                                      Just to let you know that I finalyy got it working. I finally discarded nativeProcess and came back to hostobject. I put all the jets3t library next to the swf file and then I pass this file path to the jsx to run the bat/sh/exe files. Thanks for your support on that topic. It helps knowing that you are not alone.

                                       

                                      General question: My wife asked but couldn't tell, do you have any idea of the number of people working on extensions around the world ? According to this forum participants, it doesn't look like there are a lot but it's hard to have an idea. Anyway, thios question doesn't need an answer, it is just crossing my mind.

                                       

                                      Loic