1 Reply Latest reply on Jul 28, 2008 3:10 AM by c.pfaffenbichler

    automatically changing colorswatches  problem with integrating array into »for«-operation in javasc

    c.pfaffenbichler Level 8
      I work prepress and when we get dozens of differently sized documents for ad-campaigns Id like to be able to apply the changes of Indesign-Coloswatches for the various printing-conditions as JavaScript (but Im frankly not experienced at Scripting).
      To avoid having to enter the various names, values and clauses multiple times I thought I could write six Arrays (the first a list of the names of the swatches I want changed, the second a list of the names I want them changed to, the rest lists of the new colorValues as per separation), and then run a for-operation where [i] selects the respective entries and uses them to select and change the Swatches.
      (Id like to proceed similarly with relinking the layout-images with the hires ones that have been separated for the various printing-conditions later on.)
      But either my concept is faulty from the start or Im violating a Scripting-convention because I cant get it to work.

      var myDocument = app.activeDocument;
      var theOldColors = ("C=100 M=70 Y=0 K=40", "C=0 M=15 Y=100 K=0");
      var theNewColors = ("100/70/0/40->ztg100/58/0/25", "0/15/100/0->ztg0/10/100/0");
      var cyanValues = (100, 0)
      var magentaValues = (58, 10)
      var yellowValues = (0, 100)
      var blackValues = (25, 0)

      for (var i = 0; i < theOldColors.length; i++){
      myDocument.swatches.item(theOldColors[i] ).space = ColorSpace.CMYK;
      myDocument.swatches.item(theOldColors[i] ).colorValue = new Array (Number (cyanValues[i]), Number (magentaValues[i]), Number (yellowValues[i]), Number (blackValues[i]) );
      myDocument.swatches.item(theOldColors[i] ).name = (theNewColors[i] );
      }

      Can anyone of You point me to my mistake?
      Any suggestions appreciated
      pfaffenbichler