ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Getting "undefined" error when using startTime.setValue()

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Oliver Watson
Getting "undefined" error when using startTime.setValue()
on Sep 13, 2019 at 4:47:06 pm
Last Edited By Oliver Watson on Sep 13, 2019 at 4:51:22 pm

I've written a script that splits the footage layers of a comp into multiple segments and shuffles their order. The script's final job is to sequence these layers and I'm not sure how to do that. My code is throwing a "myLayer.startTime.setValue is undefined" error.


myLayer = myComp.layer(n);
for (n = 2; <= myComp.numLayers; n++) {
previousOutPoint = myComp.layer(n - 1).outPoint - crossfade; // get the previous layer's outPoint
myLayer.startTime.setValue(previousOutpoint); // and use it to set this layer's startTime
}


Anyone know how I can move layers in the timeline with scripting?


Return to posts index

Dan Ebberts
Re: Getting "undefined" error when using startTime.setValue()
on Sep 13, 2019 at 4:55:12 pm

You're on the right track, but you set a layer's startTime like this:

myLayer.startTime = previousOutpoint;

Also, your loop control doesn't look right - should look like this:

for (n = 2; n <= myComp.numLayers; n++) {

Also, it seems like this:

myLayer = myComp.layer(n);

should be inside the loop.


Dan



Return to posts index

Oliver Watson
Re: Getting "undefined" error when using startTime.setValue()
on Sep 13, 2019 at 5:29:15 pm

Thanks so much for the prompt reply, Dan!

Ok, I fixed my code up per your suggestions and there's no error. Awesome!

However, maybe I'm misunderstanding what startTime really is, because the output I'm getting is unexpected as you can see in the image:



// SEQUENCE LAYERS
for (n = 2; &lt;= myComp.numLayers; n++) {
myLayer = myComp.layer(n);
previousOutPoint = myComp.layer(n - 1).outPoint - crossfade; // get the previous layer's outPoint
myLayer.startTime = previousOutpoint; // and use it to set this layer's startTime
}


Return to posts index


Dan Ebberts
Re: Getting "undefined" error when using startTime.setValue()
on Sep 13, 2019 at 5:36:43 pm

It looks like your capitalization within previousOutPoint is inconsistent, try changing the last line of your loop to:

myLayer.startTime = previousOutPoint;



Dan



Return to posts index

Oliver Watson
Re: Getting "undefined" error when using startTime.setValue()
on Sep 13, 2019 at 6:00:51 pm

Doh!! Embarrassing.

Thanks, Dan. You have no idea how much MotionScript and all your posts here on Creative Cow have helped me for so many years. Really appreciate it.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]