4 Replies Latest reply: May 18, 2013 3:49 AM by fabiantheblind RSS

    Javascript access from Extension Builder

    d3mac123 Community Member

      Currently I have a big Photoshop extension (made manually with several jsx files plus a Flash Builder/swf panel) that I would like to adapt to Extension Builder (mostly becase I couldn't find a way to open the panel in its proper dimensions in Photoshop, neither I am able to set the maximum resize dimensions of the panel - both things handled by the manifest.xml file in EB).

       

      Testing the process, I manually created a com.app.name file in the /Library/Application\ Support/Adobe/CS6ServiceManager/extensions folder and pasted all my documents there. I manually created a manifest.xml file under the CSXS folder. I start Photoshop and the manifest settings comes perfect, with the panel opening in the proper dimensions. The issue is, NO buttons work anymore because the main jsx file is not loaded - it seems that only the swf file was read.

       

      Any examples on how can I interact with jsx files using Extension Builder?

       

      Thanks a lot,

      Alex

        • 1. Re: Javascript access from Extension Builder
          jlmdesyn72 Community Member

          In Bundle Manifest editor (right click on extension in FB package explorer, go to CS Extension builder and there is Bundle Manifest editor), go to extension tab at bottom and then resources. There is the path for your script. Fill er in.   public function handleclick1(event:Event):void {                                    CSInterface.instance.evalScript("name of a function in your script");                                                        }

          • 2. Re: Javascript access from Extension Builder
            fabiantheblind Community Member

            Hi jlmdesynm,

             

            what do I have to add to the .mxml file to pass the event?

             

                                <mx:Button label="handleclick1" click="controller.handleclick1("EVENT GOES IN HERE?")"/>

            • 3. Re: Javascript access from Extension Builder
              jlmdesyn72 Community Member

              Here's how I handled. Mostly boilerplate from the auto-build.

               

              <s:Button  id = "whatever" width="15" height="15" toolTip="Tooltips are neat&#13;now a new line because my panel is small" click="handleclick1(event)" enabled="{hostName.indexOf('illustrator') > -1}"/>

              • 4. Re: Javascript access from Extension Builder
                fabiantheblind Community Member

                hm. I get an error.

                "Call of a probably undefined method handleclick"

                The panel gets created if I run it anyway and it has the button but nothing happens.

                 

                 

                This is my .mxml:

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

                <?xml version="1.0" encoding="utf-8"?>
                <csxs:CSExtension xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:csxs="com.adobe.csxs.core.*" applicationComplete="appComplete()">
                 <fx:Script>
                                    <![CDATA[
                
                                              import com.adobe.csxs.core.CSInterface;
                                              import com.adobe.indesign.Events;
                                              import com.adobe.indesign.Event;
                
                                              [Bindable]
                                              private var hostName:String = HostObject.mainExtension;
                
                
                                              public function appComplete():void{
                                                         CSInterface.instance.autoThemeColorChange = true;
                                              }
                
                                    ]]>
                 </fx:Script>
                
                          <s:VGroup height="100%" width="100%" verticalAlign="middle" horizontalAlign="center">
                  <s:Button  id = "whatever" width="15" height="15" toolTip="Tooltips are neat&#13;now a new line because my panel is small" click="handleclick(event)" />
                 </s:VGroup>
                </csxs:CSExtension>
                

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

                and this my .as file:

                 

                package 
                {
                          import com.adobe.csawlib.indesign.InDesign;
                          import com.adobe.indesign.*;
                          import com.adobe.csxs.core.CSInterface; 
                          public class HelloWorldInDesign
                          { 
                                    public function handleclick(event:Event):void{
                
                                              CSInterface.instance.evalScript("hello");                       
                
                                    }
                          }
                }
                

                The Script file is added as resource as you told and has single function called hello that calls an alert.

                 

                added syntax highlite