4 Replies Latest reply on Jul 29, 2010 1:25 AM by ClintGossettSF

    Transferring Custom Flash Panel to CSSDK Panel

    ClintGossettSF Level 1

      Hello,

       

      So I've got a Flash panel I created in Flex that utilizes "MMExecute" to call JSFL commands to do various things in Flash.  I'd like to move this panel into a CS Extension however, I am having a heck of a time figuring out how to get what used to work with "MMExecute" to work with "CSXSInterface.getInstance().evalScript()".

       

      1) Running an Embedded Extended Script:

           With MMExecute I'd simply embed an entire JSFL script (that decaired all of my functions and variables) into my AS3, turn the script into a string, and run MMExecute on the string (Globals.jsfl included in my sample project attached):

       

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

           private var GlobalsJSFL : Class;

           private var GlobalsJSFLString:String  = new GlobalsJSFL();

       

           private function creationCompleteHandler():void

           {

                 MMExecute( this.GlobalsJDFLString );

           }

       

            It worked great! Then I coud simply call something like this:

       

                     MMExecute( "Globals.doSomething();" );

       

       

          Now with CSXSInterface:

       

               CSXSInterface.getInstance().evalScript( this.GlobalsJSFLString )   only throws JS error.  So, I've resorted to Saving the JS script to the local system and then calling "fl.runScript" to run the script from JSFL..It's super convoluted but I can get the script to run. This sucks, do I have to write the file to the system to get it to run?

       

      2) Calls to JS always run in same JS engine? (does not seem to be the case):

       

      One of the major things I rely on for my MMExecute processes to work is that "all" calls to MMExecute from my "Panel" are run in the same JS engine.  Thus, if I declare a namespace once (say upon creation complete), I can access that namespace and any functions/variables I've associated within it at any time. 

       

      This is supper important when using functions such as "fl.getElementByType" or fl.getElementByName" as "ObjectFindAndSelect.jsfl" needs to be instantiated before these function can be called.

       

      In my original Flash panel I simply called "   MMExecute("fl.runScript(fl.configURI + 'Javascript/ObjectFindAndSelect.jsfl' );");  " on creationComplete.  Which gave all of my subsequent scripts access to it's functions. 

       

      Now I cannot find anything that I've declared in previus script calls. I cannot even get "ObjectFindAndSelect.jsfl" to run and be detected in the same script.

       

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

       

      I've created a test project which illustrates my best attempt at declaring Global function/variables and instantiating "CSXSInterface.getInstance().evalScript()" via my CS Extension.  I've tried a number of different methods to call JSFL and the method included (though convoluted) is the only way I've gotten it to work.   What am I doing wrong?

       

      Here is a link to the sample project:      http://bit.ly/deZyZ6

        • 1. Re: Transferring Custom Flash Panel to CSSDK Panel
          Bob Stucky Adobe Employee

          Are you using Extension Builder or  just the SDK and FlashBuilder?

           

          Bob

          • 2. Re: Transferring Custom Flash Panel to CSSDK Panel
            ClintGossettSF Level 1

            Just SDK and FlashBuilder...

            • 3. Re: Transferring Custom Flash Panel to CSSDK Panel
              Bob Stucky Adobe Employee

              There's some stuff not right in your project.

               

              First thing is to make sure your manifest file contains a <ScriptPath> object. Without it, your extension will not load the script and the functions declared in it will not be available.

               

              It goes in the DispatchInfo, something like this:

               

                          <DispatchInfo >
                              <Resources>
                                  <SwfPath>./main.swf</SwfPath>
                                  <ScriptPath>./jsfl/Globals.jsfl</ScriptPath>
                              </Resources>

                        ...

               

              This might get it working; but, there might also be other issues. Please let me know what you find.

               

              Bob

              • 4. Re: Transferring Custom Flash Panel to CSSDK Panel
                ClintGossettSF Level 1

                Bob, thanks for the insight.  I had made note of that "ScriptPath" node in the manifest file and never found any documentation on how to properly use it (can't say I looked too extensively for examples on the web...really just stuck to the PDF's available for the SDK).  Your comment just shed enought light on the subject to get me going.

                 

                So, I set up my project as you mentioned...and I CAN find any Objects declared in my single "scripts" file (Globas.jsfl at the mome ant).

                 

                I sill have some questions just to round out my understanding.

                 

                Still no ability to find objects declared in alternate scripts via "fl.runScript()" (e.g. "ObjectFindAndSelect.jsfl"):

                 

                One thing that still lingers is that I cannot initialize "ObjectFindAndSelect.jsfl" and  then access it's functions via "fl.*" as I can with an other script I've run in Flash.

                 

                        Adding the following to a script used to give the script access to the functions in ObjectFindAndSelect.jsfl:

                 

                fl.runScript(fl.configURI + 'Javascript/ObjectFindAndSelect.jsfl' );
                

                 

                       The solution does not work in the example I've uploaded.

                 

                I've resorted to essentially copying the contents of "ObjectFindAndSelect.jsfl" into my "Globals.jsfl" file and simply accessing  the functions from there. This  is  a workaround  I'm willing hang onto for the time being but I'd really like to know why calls to "fl.runScript()" don't end up declaring objects that can be seen by subsequent calls to "CSXSInterface".  If they did, my original method for declaring "vars" would have worked (not that I was particularly fond of the method).

                 

                Also...is there a way to add multiple "script files" to a project for the sake of organization and abstraction?


                I've up-loaded a new sample  project (set up to use the "SciptPath") that illustrates the "fl.runScript()" issue mentioned above.  Thanks again.

                 

                http://tinyurl.com/28nbnlq