Forum Replies Created

Page 123 of 1081
  • Expressions have no memory, or any way to pass results from one frame to the next. In this case I think your expression will (on each frame) have to re-calculate, frame-by-frame, everything that has occurred prior to the current time to come up with the correct result for the current frame.

  • Dan Ebberts

    January 15, 2021 at 9:52 pm in reply to: Variable Frame Rate with Posterize Time

    I think what you’re going to need is a time remapping expression that adds up your sampleImage keyframe values for all frames prior to the current time and uses that to calculate how much time has elapsed. Could get pretty slow if your comp is long though…

  • 1. If you don’t declare the i variable locally, JavaScript will create a global one for you. You’ll probably get away with it, but you could get into trouble if you already have one declared globally and you start using it locally to control your for loop.

    2. That’s just checking to see if the layer actually has any masks. My assumption was no masks = no keyframes, but you may want to handle that situation differently (just skip that layer maybe?)

    3. If you don’t already have Jeff Almasol’s incredibly useful rd_GimmePropPath.jsx script you should get it. I use it all the time to examine complex property hierarchies and get the match names for properties.

  • This seems to work:

    var currentComp = app.project.activeItem;

    var errorArray = [];

    for (var i = 1; i <= currentComp.numLayers; i++){

    if (currentComp.layer(i).property("ADBE Mask Parade").numProperties == 0){

    errorArray.push(i);

    }else{

    if(currentComp.layer(i).property("ADBE Mask Parade").property("ADBE Mask Atom").property("ADBE Mask Shape").numKeys == 0){

    errorArray.push(i);

    }

    }

    }

    if (errorArray.length == 0){

    alert("0 Layers with no keyframes");

    }else{

    for (var i = 0; i < errorArray.length; i++){

    alert("Layer #"+errorArray[i]+" has no keyframes","Error");

    }

    }

  • Dan Ebberts

    January 8, 2021 at 9:37 pm in reply to: How use seedrandom and if expressions?

    I haven’t tested this, but I think it would be more like this:

    X = thisComp.layer("Null 5").effect("Slider Control1")("Slider");

    if ( X < 14){

    seedRandom(X,true);

    Math.floor(random(14));

    }else{

    thisComp.layer("Null 5").effect("Slider Control 2")("Slider")

    }

  • Dan Ebberts

    January 1, 2021 at 8:14 pm in reply to: Text Expression for multiple styles and data values

    An expression can’t set multiple styles for different parts of the same text layer. All characters get the same style. Probably the best you can do is use different text layers for each part and position them using sourceRectAtTime().

  • Dan Ebberts

    January 1, 2021 at 6:23 pm in reply to: Selected Layer

    Maybe like this:

    var activeItem = app.project.activeItem;

    var selectedIndex = activeItem.selectedLayers [0].index;

    activeItem.layer (selectedIndex-1).selected = true;

    activeItem.layer (selectedIndex).selected = false;

  • I think what you want instead of newMaskShape.value is newMaskShape.keyValue(1) and newMaskShape.keyValue(2). Also, don’t forget the semi colons at the end of your statements.

  • Dan Ebberts

    December 28, 2020 at 5:15 pm in reply to: Trigger animation based on hold keyframe?

    This should work:

    fadetime = 0.5;

    dur = 2;

    p = position;

    val = 0;

    if(p.numKeys > 0){

    n = p.nearestKey(time).index;

    if(p.key(n).time > time) {

    n--;

    }

    if(n > 0){

    t = p.key(n).time;

    if(time < t+dur){

    val = linear(time, t, t+fadetime, 0, 100);

    } else {

    val = linear(time, t+dur, t+dur+fadetime, 100, 0);

    }

    }

    }

    val

  • Dan Ebberts

    December 26, 2020 at 3:42 pm in reply to: Give me the way to reverse Expresstion

    That’s a strange expression. It appears that the first chunk, down to the

    }delay = 0.05;

    line, doesn’t actually do anything. Getting the last part to run in reverse would be tricky, because it doesn’t really have an end time (it’s an exponentially decaying cosine wave), so it would be hard to pick a start time for the reverse action.

Page 123 of 1081

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