Skip navigation
Currently Being Moderated

Javascript access from Extension Builder

May 15, 2013 8:03 AM

Tags: #photoshop #javascript #jsx #jsxbin

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

 
Replies
  • Currently Being Moderated
    May 16, 2013 11:00 AM   in reply to d3mac123

    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");                                                        }

     
    |
    Mark as:
  • Currently Being Moderated
    May 16, 2013 11:36 PM   in reply to jlmdesyn

    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?")"/>

     
    |
    Mark as:
  • Currently Being Moderated
    May 17, 2013 8:02 AM   in reply to fabiantheblind

    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}"/>

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2013 3:49 AM   in reply to jlmdesyn

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points