Skip to main content

JavaScript Utility

Pro Feature

Pro features are only available with a Professional licence. To upgrade, visit cavalry.scenegroup.co.

Intro

The JavaScript Utility can be used to set Attributes, create custom simulations, Distributions and more.

For more information on how JavaScript can be used across all JavaScript Layers see JavaScript Layers.

See JavaScript Layers

UI

Expression Window - Enter a JavaScript expression here.

+ Button - Add a new Variable.

n0 - A default (double) Variable.

Example

Making a String Array in JavaScript.

  1. Create a Text Shape.
  2. With the Text Shape selected, click the Duplicator icon in the Shelf.
  3. Create a JavaScript Utility.
  4. Copy and paste the below into the expression window.
var animation = [
"2d",
"3d",
"Cel"
];
animation[ctx.index]
  1. Connect javaScript.id > text.string

The first three Text Shapes in the Duplicator will read 2d, 3d and Cel.

In order to loop each index within the array, edit the last line to read animation[ctx.index % animation.length]

It's possible to add line breaks by adding \n to a string. e.g. 2d\nrules will output:

2d
rules
See ScriptingExample JavaScript Expressions