5 Replies Latest reply on Mar 9, 2008 9:10 AM by [Jongware]

    How to  name a color

    Tom Tomasko Level 1
      Hello,

      I need to fill a text box with a color. If I use the name of an already defined swatch the following line works. But if I try to use the CMYK color values (the swatch is not in the swatch panel) instead, it does not work.

      The first line works. What is wrong with the second line?

      myTextFrame.fillColor = myDoc.colors.item("Lime");
      myTextFrame.fillColor = myDoc.colors.item(colorValue:[0,100,100,0]);

      Thanks,
      Tom
        • 1. Re: How to  name a color
          Level 1
          The swatch doesn't exist, so you must create it first using (paradoxically):

          mySwatch = myDoc.colors.add({colorValue:[0,100,100,0], colorModel:ColorModel.process, colorSpace:ColorSpace.cmyk);

          then you can use:

          myTextFrame.fillColor = mySwatch;

          Dave
          • 2. Re: How to  name a color
            Tom Tomasko Level 1
            Thanks Dave, that works. But two other questions arise.

            I want to change the background color of text boxes that do not meet certain criteria for size and position. This makes it easier to find text boxes in a 400 page book that are a bit off. I'm sure I'll have some questions much later about how to accomplish this.

            But for now:

            1. When I am done I want to change the background color back to "None." But when I put "None" or "[None]" in the first line I wrote above, the word is not recognized. "Paper" is recognized, but that is a white background. I need no color.

            2. Each time I use your script to create a color I recreate it over and over again. I haven't tried using try/catch to make sure there is only one instance of the color. I'm sure that would work. But when I am all done, I want to delete from the swatch panel all the colors I just created. In fact, deleting all colors except none, paper, black and registration would be real good.

            So how can I delete colors?

            Thanks,
            Tom
            • 3. Re: How to  name a color
              Tom Tomasko Level 1
              I figured out how to make the text box background revert to "None":

              myTextBox.fillColor = myDoc.swatches.item("None");

              Tom
              • 4. Re: How to  name a color
                Tom Tomasko Level 1
                And I just figured out how to remove a color from the swatches panel:

                myDoc.swatches.item("name of swatch").remove();

                Now I'll play around with how to delete all colors except the ones mentioned two messages ago.

                Tom
                • 5. Re: How to  name a color
                  [Jongware] Most Valuable Participant
                  >Now I'll play around with how to delete all colors except the ones mentioned two messages ago.

                  A hint: You don't have to use the actual colour names to reference swatches. The ones you
                  i don't
                  want to delete are index numbers 0 to 3. Go from there ;-)