• How to fix Syntax: Unexpected token )

# How to fix Syntax: Unexpected token )

New Here ,
Jul 09, 2022 Jul 09, 2022

Copied

Hello! I'm still trying to grasp AE here! So I'm currently trying to code an automatic ranking system like one here:

But I keep getting the error message below

My CS friends explained it's most likely because I misplaced a closing bracket somewhere but we've been staring at it for hours and we still can't figure out where's the mistake. Does anyone know where I may have messed up?

`pi = 0;
dt = effect("RankTransTime ")("Slider");
sTime = Math.floor(time/dt)*dt;
z = [0,0,0,0];
if (time - sTime < 0.1){
n = effect("n")("Slider");
if (Math.floor(n/4) >= pi){
let r = [];
for (i = 1; i <= n; i++){
ssTime = thisComp.layer(i).masterProperty("time").valueAtTime(sTime);
if (ssTime == 0) ssTime = (n-1)/1000;
let obj = {t: ssTime, id: i};
r[i-1] = Object.assign({}, obj);
}
r. sort(function(a,b){return b.t - a.t});
for (i = 1 <= 4, i++){
z[i-1] = r.findIndex(function(a)return a.id == i + (pi*4)})/20;
}}
z `

TOPICS
Error or problem , Expressions , How to , Scripting

Views

65

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
3 Replies 3
New Here ,
Jul 09, 2022 Jul 09, 2022

Copied

The code can be found here!

```````pi = 0;
dt = effect("RankTransTime ")("Slider");
sTime = Math.floor(time/dt)*dt;
z = [0,0,0,0];
if (time - sTime < 0.1){
n = effect("n")("Slider");
if (Math.floor(n/4) >= pi){
let r = [];
for (i = 1; i <= n; i++){
ssTime = thisComp.layer(i).masterProperty("time").valueAtTime(sTime);
if (ssTime == 0) ssTime = (n-1)/1000;
let obj = {t: ssTime, id: i};
r[i-1] = Object.assign({}, obj);
}
r. sort(function(a,b){return b.t - a.t});
for (i = 1 <= 4, i++){
z[i-1] = r.findIndex(function(a)return a.id == i + (pi*4)})/20;
}}
z ```````

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 09, 2022 Jul 09, 2022

Copied

The line

for (i = 1; <= 4, i++)

makes no sense. I'm also not clear what your sort function is supposed to do. You also have some extraneous spaces in your code, which is critical as it breaks inheritance. The whole code seems incomplete.

Mylenium

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 09, 2022 Jul 09, 2022

Copied

LATEST

If you are trying to change the position and order of multiple layers based on a changing value for each layer driven by some data or a slider, the workflow in the tutorial is not the workflow I would use.

The tutorial is too painful to watch, so I am not sure where you apply this expression. The only thing I got out of the tutorial was that the author was making a MOGRT to be used in Premiere Pro.

Tell us where you apply the expression and show us a screenshot by embedding, not uploading using the "Drag & Drop here..." option. Select the layer with the problem code, press the 'u' key twice to reveal all modified properties, take a screenshot, select the screenshot file and copy and paste it to your post, drag it into your post, or use the Toolbar so we can see what you are doing.

I agree with Mylenium 100%. The expression you shared is incomplete.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Troubleshooting FAQs
After Effects Community Recap
Getting started with After Effects