You’ve just created the coolest extension you’ve ever seen, almost. It really needs to support drag and drop; but, that seems like so much work; and, there are no decent, real world examples of how to do it.
Solution
How about we fix that. Here’s a decent example of how to do drag and drop between CS extensions and their CS host applications (both ways, even!).
You need to add C/C++ functionality to one of the Creative Suite applications and you need your custom code to work together with an Actionscript-based CS Extension. Where do you start?
Solution
You will need to create two separate projects:
1) You will need to create a native plugin using Visual Studio and/or XCode using the SDK provided for the point product you are developing for.
2) You will need to create a CS Extension using the CS SDK / Extension Builder.
These two entities can then work together as described below.
Creating menus which extend beyond panel bounds in CS Extensions very often requires the use of a "NativeComboBox". NativeComboBox uses NativeMenu. When clicking on a NativeMenu, a button below the menu can have its state change incorrectly to the down state.
So you've made this really cool extension that runs under more than one CS product. That being the case, it's quite possible your user will have the extension open in more than one CS app at a time. If that should happen, it might (depending on what your extension does) be nice to have the extensions show the same data all the time across all instances of the extension.
Solution
This recipe will demonstrate one way to use CSXS Events to synchronize data models between two instances of the same extension running under different CS products.
UndoModes in InDesign (CS4 and later) allow for multiple steps in a script to be saved as a single step in the undo stack. Using this capability in a CS SDK extension is not very straight-forward because you can't pass in ActionScript code to a doScript. doScript() accepts one of the three scripting languages which ActionScript is not one.
Solution
Use one of the native scripting languages as the argument of the doScript(). There are many ways of approaching this as described below.
You need the ability to call JavaScript functions from the Creative Suite SDK (CS SDK) and vice versa.
Solution
In the following code, I'll explain how to use HostObject to communicate between JavaScript and the CS SDK. This will involve embedding your JavaScript in your swf and defining interfaces for communication between the two different contexts. Note, this recipe will not cover using CSXSInterface.evalScript but that is another viable method for communicating from the CS SDK to JavaScript.
Based on Flash and ActionScript, the CS SDK has no equivalent statement to ExtendScripts "eval()" function. That is just one reason why using BridgeTalk with a CS SDK extension makes little sense in an ActionScript context. Without BridgeTalk, how do you talk between Creative Suite applications and extensions?
Solution
One solution is to use CSXSEvents between the CS SDK Extensions. This would work fine providing the host applications both support CSXS. But that leave Bridge and Air Applications out in the cold. Another solution is to set up socket communications between an extension and whatever wants to communicate with it. Using sockets makes it easy to communicate from Air applications to CS SDK Extensions.
UndoModes in InDesign (CS4 and later) allow for multiple steps in a script to be saved as a single step in the undo stack. Using this capability in a CS SDK extension is not very straight-forward because you can't pass in ActionScript code to a doScript. doScript() accepts one of the three scripting languages which ActionScript is not one.
Solution
Use one of the native scripting languages as the argument of the doScript(). There are many ways of approaching this as described below.
When using a ComboBox, the menu for the ComboBox is clipped by the stage. If you need wide menu items, you have little choice by place the ComboBox so that this isn't an issue.
Solution
This example extends a ComboBox to use the NativeMenu class (flash.display.NativeMenu) to display the menu for the ComboBox, eliminating this problem.
So you've made this really cool extension that runs under more than one CS product. That being the case, it's quite possible your user will have the extension open in more than one CS app at a time. If that should happen, it might (depending on what your extension does) be nice to have the extensions show the same data all the time across all instances of the extension.
Solution
This recipe will demonstrate one way to use CSXS Events to synchronize data models between two instances of the same extension running under different CS products.
This site is produced in partnership with O'Reilly.