Skip navigation
Currently Being Moderated

Apply Color in arrays

Jun 19, 2012 10:11 AM

Hi all,

 

I am new to script. While working on CS3 scripting Guide i am creating a new paragraph style and apply all the properties like fontsize, fontstyle, fillcolor, filltint etc.... But in fillColor suppose i am using the name like (red, cyan etc) it works, but if i use like [100, 0, 0, 0] it not works.  See the fifth line FYI.

 

Where i did a mistake.

 

1. var myDocument = app.activeDocument;

2. var myPstyle = myDocument.paragraphStyles.add({name: "H1"});

3. myPstyle.pointSize = 18;

4. myPstyle.fillColor = "red";

 

5.  //myPstyle.fillColor = [15, 100, 100, 0];

 

 

And one more doubt.

 

For Creating New ParagraphStyle:

app.activeDocument.paragraphStyles.add();

 

For Creating New CharacterStyle:

app.activeDocument.characterStyles.add();

 

 

Is it correct:

 

For Creating Swatches:

app.activeDocument.swatches.add();

 

 

Thanks in advance. Again for your remembrance i am a learner in scipt.

 
Replies
  • Currently Being Moderated
    Jun 19, 2012 10:30 AM   in reply to Learner X

    Swatches and colors are confusing. Swatch is sort of a virtual superclass, like PageItem, and has no add() method. In your case, you want:

     

    myPstyle.fillColor = myDocument.colors.add({colorValue: [15, 100, 100, 0]});

     

    Jeff

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points