Following the merge text extensions for Flash, Illustrator, and InDesign, Keith Gilbert wrote me wondering about getting swatch information from InDesign to Flash via XFL or by way of importing an Adobe Swatch Exchange (ASE) file into the Flash swatches panel. There are several stumbling blocks in the way of such an extension. First, finding a way for extendscript or JSFL to read the contents of an ASE file (which is not open source and not plaintext) proves to be quite difficult. Second, JSFL (the Flash scripting language) doesn’t have any access (currently) to the swatches panel.
—
BREAKING NEWS (12/6/08): I noticed that the new Kuler extension for Flash CS4 has an “add to swatches” button, and it actually adds swatches to the swatches panel. After some decompiling and a lot of detective work, I found an undocumented JSFL call that was added to CS4. The feature is undocumented for a reason: it sends encoded XML data, and if the data is faulty, it crashes Flash. I have a few test cases working and I’m confident that I can add it to this extension, so the swatches will go right in the Flash swatches panel, rather than onto the stage, though it will only work in CS4. Be on the lookout for an update in the next few days.
UPDATE (12/7/08): Updated to version 1.1.0. If you have Flash CS4, the swatches will now go right into your Flash Swatches panel. Hooray!
—
There does seem to be a lot usefulness to such an extension, since XFL creates a new workflow between InDesign and Flash, and the Illustrator importer for Flash is fantastic, but neither one loads any of the swatches from the original document. I’ve certainly spent my fair share of time opening up the swatch properties, making sure the swatch is RGB or hex and copying all three fields one at a time.
So, I decided to plow ahead and see what I could come up with. The results are below. This extension takes the swatches from your current InDesign or Illustrator document and sends them to a new layer on the Flash stage. You can then use the eyedropper to pick up the colors, or you can add them to your swatches panel individually (similar to this demo of the Kuler panel).
UPDATE (12/7/08): If you have Flash CS4, you can skip the step above. Version 1.1.0 of this extension will send the Illustrator or InDesign swatches right to your swatches panel in Flash.
This extension will transfer spot and process colors of all varieties (RGB, CMYK, LAB, HSB). Rather than converting the CMYK with my own function, I used the applications themselves to convert the colors to RGB for Flash, so the transfer fidelity is quite good. It will ignore gradients, tints, patterns and fancy stuff like that. If you want to get your gradients into Flash see the bonus tip below.
InDesign to Flash CS4
Or, here’s what InDesign to Flash CS3 would look like.
Illustrator to Flash CS4
Or, here’s what Illustrator to Flash CS3 would look like.
Downloads and more below the fold.
Downloads
- Send Swatches to Flash.jsx (CS3, CS4)
- Send Swatches to Flash (ID).mxp (CS4)
- Send Swatches to Flash (AI).mxp (CS4-US only)
Installation
JSX file:
- Place the JSX file into the appropriate directory:
InDesign CS3/CS4 > {application directory**}/Scripts/Scripts Panel
Illustrator CS3 > {application directory**}/Presets/Scripts
Illustrator CS4 > {application directory**}/Presets/{language/region}/Scripts
**Application Directories:
Windows > C:\Program Files\Adobe\{application name + version}\
Mac OS X > Applications/{application name + version}/
MXP file (CS4 only):
- Double-click on the MXP file to install using Adobe Extension Manager CS4.
Usage
InDesign: make sure the scripts panel is open, Windows > Automation > Scripts, locate the Send Swatches to Flash.jsx script and double-click to run the script. If you installed the script using the MXP file, the script with be in the Ajar Productions subfolder.
Illustrator: Select Send Swatches to Flash from the File > Scripts menu.
Bonus Tip: Transferring Gradients
You can get a gradient from Illustrator to Flash by applying the gradient to a rectangle, copying the rectangle and pasting into Flash (CS3 or later). A dialog box will appear in Flash, make sure “Paste using AI File Importer preferences” is selected and it will retain you vector artwork, including the gradient! To get the gradient from InDesign to Flash, create the rectangle with the gradient in InDesign, copy and paste it into Illustrator, then copy and paste it into Flash using the instructions in the previous sentence.
FYI
Get updates from Ajar Productions
Sign up today and get the InDesign Split Text premium extension for free!
i am trying to export my swatches from ill4 to flash4
i have loaded your script into illustrator and when i use the script from ill. i get an error:
Error 2: apps is undefined.
Line: 27
-> for(var i=apps.length-1; i>0; i–) {
what does this mean?
thank you
Adrian, the variable “apps” is used to loop through and check for all versions of Flash, so the swatches can be sent to CS3 as well, if that’s the version of Flash that is open.
I have yet to encounter this problem on any of my own machines, so I don’t know why the “apps” variable would be undefined.
To fix: locate the script file, open it in a text editor, find the offending line, add a return before it, and paste this code:
if(!this.hasOwnProperty("apps")) return "flash";
Hopefully that should bypass the problem. Let me know how it works.
If anyone else has this problem, please let me know, I’ll be sure to incorporate a fix into the next version.
wow, this is awesome! I’m having a problem similar to Adrian’s but not exactly. When I run the script in Illustrator, I get this error:
Error 21: undefined is not an object.
Line: 86
-> var red =
Math.round(rgbArray[0]).toString(16)
do I have a color that’s defined wrong in Illustrator?
-Kiki
Kiki,
Yes, it looks like the script is running into a color it can’t convert. There are 2 ways to try and diagnose the problem:
1) Delete colors one at a time, until you can generate the error with one swatch in your palette, then send me the info on that swatch.
2) Post the Illustrator file somewhere (you can delete the content and leave the swatches) and I can use the file for testing.
If I can replicate the error with your help, we should be able to find a fix.
Hey, thanks for offering this awesome script. I also had that apps. error thanks for the fix
Awesome!!!!
Cool extension, thank!
This is extremely useful. Once again I cannot understand why an obvious function like this has to be implemented by someone in his spare time. Thank you very much!
Thanks, Herr Moose! If they made everything perfect, then what would I do with my spare time?
I am getting the same error as adrian wolfson, and the fix you posted works correctly. I am on 64bit Vista, AI and Flash CS4. It might be a good idea to put the fix in the download file, if this script is still maintained.
Very useful script for such a frustrating gap between Adobe products.
Delfield, The files have been updated (new version is 1.1.1). Thanks for your comments.