Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Getting “undefined” error when using startTime.setValue()

  • Getting “undefined” error when using startTime.setValue()

    Posted by Oliver Watson on September 13, 2019 at 4:47 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?

    Oliver Watson replied 6 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 13, 2019 at 4:55 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

  • Oliver Watson

    September 13, 2019 at 5:29 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
    }

  • Dan Ebberts

    September 13, 2019 at 5:36 pm

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

    myLayer.startTime = previousOutPoint;

    Dan

  • Oliver Watson

    September 13, 2019 at 6:00 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.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy