Copy link to clipboard
Copied
I know very little about AE and am not delusional about being able to learn it all quickly. That's why I'm grateful for a site I found with the expressions I needed to just copy and paste. Their Wiggle expression worked great, but I'm having trouble with their Squash and Stretch expression. Here is what they provide, copied and pasted exactly:
maxDev = 13; // max deviation in pixels
spd = 30; //speed of oscillation
decay = 1.0; //how fast it slows down
t = time - inPoint;
x = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
y = scale[0]*scale[1]/x;
See the screenshot for the error I'm getting:
I have searched this forum already, and plenty of new users have seen this error. The common solutions I've read so far are:
I also read somewhere that the expression engine has changed, and expressions that used to work no longer do. I suspect this is the problem. The page I copied the expression from was written in 2017, and I'm using the latest AE (updated approximately a week ago). I have a feeling this expression used to work and doesn't anymore.
Can anyone help me fix it? Thanks in advance!
You left off the last line:
maxDev = 13; // max deviation in pixels
spd = 30; //speed of oscillation
decay = 1.0; //how fast it slows down
t = time - inPoint;
x = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
y = scale[0]*scale[1]/x;
[x,y]
Copy link to clipboard
Copied
You left off the last line:
maxDev = 13; // max deviation in pixels
spd = 30; //speed of oscillation
decay = 1.0; //how fast it slows down
t = time - inPoint;
x = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
y = scale[0]*scale[1]/x;
[x,y]
Copy link to clipboard
Copied
Astounding! Thank you so much! That worked like a charm. I would have had NO WAY of knowing that was the issue in my present state of ignorance (which as of reading your reply is sliiiiiiightly less ignorant). I suppose I was barking up the wrong tree, because AE said an error was in Line 1. I am interested in learning what all of this means of course but that will take time.
Just curious, would this expression have worked before, in previous versions of AE? Because I checked the source, and I didn't accidentally leave out the line... the way I copied it is in fact the way they posted it... see screenshot:
They didn't include the last line either. So perhaps it used to work without it?
And, I'm assuming you're "the famous" Dan Ebberts... if so, I'm privileged to have you answer my question. Thank you again!
Copy link to clipboard
Copied
I don't know about famous, but I can tell you that I believe that expression originally came from an old page on my site:
https://www.motionscript.com/expressions-lab-ae65/squash-and-stretch.html
where the last line is present, as it needs to be.
It seems that the new JavaScript engine does sometimes mistakenly point to line 1 for errors. I've filed a couple of bug reports on it, but as far as I know, it hasn't been fixed yet.
Dan
Copy link to clipboard
Copied
The expression - without the last line - was never working this way in no version of AE.
In JavaScript as well as in ExtendScript, the last value written or calulated is the one in use. Even if you calculate x and y in the lines above, you must enter [x,y] in order to "present" the values.
Can you post the link to the source of this expression site?
There are a lot of copy/past code snippets out there from people how have no glue of what they are talking about. So it's importend to have some "trustful" sites to check, like https://www.aenhancers.com/ and of course the famous Dan Ebberts https://motionscript.com/
I learned a lot about expressions from the language reference (https://helpx.adobe.com/after-effects/using/expression-language-reference.html), as well as code snippets. I never just copy/paste them, but always went through the lines and understand what is going on there. Spent a whole afternoon once just to understand 4 lines from Mr. Ebberts, but it was worth the time.
After Effects is not very good in pointing you to the actual line, or even give you meaningful expression errors. Sometimes you just miss an ";" and it tells you something about "arrays out of index".
*Martin
Copy link to clipboard
Copied
Oh man oh man. Mr. Ebberts, they most certainly took that from your site. There's no way they didn't. But they should have made sure it was complete. Personally, I think it would have been more professional of them to link to you instead of just copy your expression.
I found it at https://www.cinecom.net/after-effects-tutorials/super-easy-animations-expressions/. The young guys who run this site are super enthusiastic and they do know a lot of cool tricks... I think ? that's their full-time business. But yeah, they should have just linked to you instead.
Thank you, Martin, for your insights and links as well. This is all very enlightening. I think I'm going to head to those links from now on right away, instead of "googling" expressions I need.