JSX scripting makes controlling Adobe Creative Suite from an extension you’re developing a breeze. Scripting opens up the realm of creating guides, selecting tools, creating layers, running filters, and so on. To get you started, Adobe Extension Builder creates a basic *.jsx file with a sample function in every new project:
function jsxFunction() { // ... your code goes here ... return '<object><property id="success"><true /></property></object>'; }
To call that function from AS3, it’s easy:
var result:SyncResult = CSXSInterface.instance.evalScript('jsxFunction');
The Workflow
First, install the Scripting Listener plugin. With it installed, whenever you do something in Photoshop/Illustrator/etc, it will write the code needed to perform those steps to ScriptingListenerJS.log on your desktop. Copy the parts you need from there and put them in your *.jsx file, wrapped in a function. Then just call evalScript() with the function name, and you’re good!
Function Arguments
Sometimes you might need to pass a value to a JSX function from AS3—maybe it’s a coordinate, maybe it’s the path of a file, maybe it’s a color. Arguments is where life gets janky. In CS4 products, Continue reading