1

Photoshopで次のことを行うJSスクリプトを作成しようとしています。

var textarray = array("Hello World", "Good morrow", "top of the morning");

配列内の各単語について

  1. 新しいドキュメントを開く
  2. 単語をレイヤーに書き込む
  3. フォトショップアクションを実行する
  4. 保存して閉じます

これはこれまでの私のコードです。

var textarray = [ "Hello World", "Good morrow", "top of the morning" ];


for (x=0; x < textarray.length(); x++) {


#target photoshop
app.bringToFront();

var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.INCHES;
app.preferences.typeUnits = TypeUnits.POINTS;

var docRef = app.documents.add(7, 5, 72);

// suppress all dialogs
app.displayDialogs = DialogModes.NO;

var textColor = new SolidColor;
textColor.rgb.red = 255;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;

var newTextLayer = docRef.artLayers.add();
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.contents = textarray[x];
newTextLayer.textItem.position = Array(0.75, 0.75);
newTextLayer.textItem.size = 36;
newTextLayer.textItem.color = textColor;

app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
docRef = null;
textColor = null;
newTextLayer = null;

// DO ACTION HERE 
//CLOSE AND SAVE
}

何らかの理由で機能していないのは配列部分です。エラー24:textarray.lengthは関数ではありません

4

1 に答える 1

6

元の質問に答えるのはarray( ... )、JavaScriptで配列を作成する方法ではありません。

var textarray = [ "Hello World", "Good morrow", "top of the morning" ];

次の問題(実際には別の質問になるはずです)lengthは、関数ではなくプロパティです。

for (x=0; x < textarray.length; x++) { 
    ...
于 2012-05-29T07:58:27.523 に答える