5 Replies Latest reply on Jan 28, 2011 8:50 AM by Jennifer IceRider

    Returning data from JSFL to CSXS extension

    Jennifer IceRider Level 1

      I have a CSXS flash extension that I load in Flash Pro  CS5. From the CS SDK extension I invoke JSFL function in my AS3 code using the :

       

          var syncResult:SyncRequestResult=CSXSInterface.instance.evalScript("myJSFL");

       

      The JSFL script gets loaded and the function is invoked as I can see trace statements spitting text in the Flash output console.

       

      However my function in JSFL tries to return a simple string value and unfortunately no matter what I try the  syncResult.data is always undefined. The syncResult.status is set to complete so the call is going thru. Just the  data from JSFL is not being marshalled  back to my CS SDK extension.

       

      Is there a special way to get data across the JSFL-CSXS boundary ? In  my Photoshop extension I can have JSX return an XML snippet and  the CS SDK Photoshop extension works fine. So what is the trick for Flash JSFL scripts ?

       

      JSFL Script -


      function myJSFL() {

           fl.trace("called myJSFL");

           return "something";

      }

        • 1. Re: Returning data from JSFL to CSXS extension
          Jennifer IceRider Level 1

          BTW I also tried to pass as AS3 object reference into the evalScript call as a parameter -

           

              var syncResult:SyncRequestResult=CSXSInterface.instance.evalScript("myJSFL", this);

           

          And then in JSFL, I used the object ref to invoke a AS3 callback:

           

          var asInterface = {};
          function myJSFL(wrapper) {
              var asInterface = wrapper;

           

              fl.trace("myJSFLHello");

           

              asInterface.documentOpenCB("somnething..");

          ...

           

           

          But that doesn't work as I geta SyncResult - invalid param status. So you can't pass obj ref it seems via evalScript call!

          • 2. Re: Returning data from JSFL to CSXS extension
            david_a_clark Adobe Employee

            You should format return data from your JSFL function as shown in the API reference for CSXSInterface.evalScript(). For example:

             

            <object><property id="strValue1"><string>Hello</string></property></object>

             

            In general I believe you can format return values using the syntax defined here. Here's a slightly more complex example involving an array, please excuse the poor formatting.

             

                var xml = '<object>';
                xml += '<property id="myProp"><number>12</number></property>';
                xml += '<property id="myArray"><array><property id="0"><number>27.5</number></property><property id="1"><string>Hello there!</string></property></array></property>';
                xml += '</object>';
                return xml;

            • 3. Re: Returning data from JSFL to CSXS extension
              Jennifer IceRider Level 1

              David -

               

              I did try that, my PS CS4 plugin uses the XML syntax to pass data back from  a JSX script to PSD CSXS extension. However for  Flash CS5, that SyncResult.data always comes out as undefined.

               

              I am including the JSFL script path in the manifest.xml via the ScriptPath tag. The script is obviously getting loaded otherwise I won't be able to invoke its methods.

               

              Is the XML way supported for Flash CS5 or is that for Flash CS4 extensions only ?

              • 4. Re: Returning data from JSFL to CSXS extension
                david_a_clark Adobe Employee

                The example I posted above worked fine for me in Flash CS5. Perhaps you could post an example of the XML you are failing to return?

                • 5. Re: Returning data from JSFL to CSXS extension
                  Jennifer IceRider Level 1

                  oops! I got it to work.  Thanks David.  The issue was I was embedding the script as well as specifying it in the manifest, removed the Embed line and lo and behold the data is there in AS3.