Copy link to clipboard
Copied
Hello! So I have been following this tutorial below to try to make my own ranking system in AE:
I've followed the tutorial step by step when typing the code but then I came into this issue below which puzzles me since I have already placed the semicolon in that line.
Anyone know what I can do this fix this? Cheers!!
Copy link to clipboard
Copied
Just in case anyone wants to see the entire code, here it is!:
pi = 0;
dt = effect("RankTransTime ")("Slider");
sTime = Math.floor(time/dt)*dt;
z = [0, 0, 0, 0, 0];
if (time - sTime < 0.1){
n = effect("n")("Slider");
if (Math.floor(n/5) >= pi){
let r = [];
for (i=1, i <= n; i ++){
ssTime = thisComp.layer(i).masterProperty("Slider").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; i <= 5, i++){
z[i-1] = r.findIndex(function (a){return a.id == i + (pi*5)}/20;
}
}
}
Copy link to clipboard
Copied
My guess is that you're using the Legacy ExtendScript expression engine instead of the JavaScript engine. Change that in File > Project Settings > Expressions.
Copy link to clipboard
Copied
Oh the codes before did not work until I changed it to the Legacy Extendscript engine before though. Will changing it back affect the previous codes?
Copy link to clipboard
Copied
Possibly--it depends on the code. There are some differences, so you may have to edit your code to get it to run on one engine or the other.
Copy link to clipboard
Copied
I changed it back to JavaScript and line 1 had the error:
"SyntaxError: Unexpected token)
Copy link to clipboard
Copied
Hard to say for sure without setting everything up the way the tutorial has it, but I do see several syntax errors in your code.
for (i=1, i <= n; i ++){
should be:
for (i=1; i <= n; i ++){
for (i = 1; i <= 5, i++){
should be:
for (i = 1; i <= 5; i++){
and
z[i-1] = r.findIndex(function (a){return a.id == i + (pi*5)}/20;
should be:
z[i-1] = r.findIndex(function (a){return a.id == i + (pi*5)})/20;
But this code definitely needs the JavaScript engine, because it's using array.sort()
Copy link to clipboard
Copied
Object.assign({}, obj)
It probably should read object.assign. Case-sensitivity matters in JS...
Mylenium
Copy link to clipboard
Copied
I'll give it a shot but iirc, the error message popped up before I even typed in that line 😕