Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using a marker with specific name to trigger animation multiple times

  • Using a marker with specific name to trigger animation multiple times

    Posted by Andrew Millen on March 14, 2019 at 2:03 am

    I’ve got two markers on a shape layer each called “Click.” I use this expression to animate the scale:


    rampStart = marker.key("Click").time;
    rampEnd = marker.key("Click").time + .15;
    startVal = [100,100];
    maxVal = [85,85];

    rampMid = rampStart + (rampEnd - rampStart)/2;
    if (time < rampStart || time > rampEnd){
    value
    }else if (time < rampMid){
    ease(time,rampStart,rampMid,startVal, maxVal)
    }else{
    ease(time,rampMid,rampEnd,maxVal,startVal)
    }

    Using the code found here, I want to replace the “wobble” effect with my own scale expression above AND have it specify the marker by name, not just any marker on the layer.


    n = 0;
    t = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time) n--;
    }
    if (n > 0) t = time - marker.key(n).time;

    amp = 15;
    freq = 5;
    decay = 3.0;

    angle = freq * 2 * Math.PI * t;
    scaleFact = (100 + amp * Math.sin(angle) / Math.exp(decay * t)) / 100;
    [value[0] * scaleFact, value[1] / scaleFact];

    But I’m not conversant enough in expressions to make it happen. Can anyone help? I’m sure it’s super obvious to someone who knows what they’re doing.

    Andrew Millen replied 7 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Oleg Pirogov

    March 14, 2019 at 4:38 am

    I suppose you only need to add a line that checks, if the comment of nearest (from the left) marker equals “Click”:

    theMarker = marker.key("Click");

    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time) n--;
    if (n!== 0 && marker.key(n).comment == "Click") theMarker=marker.key(n);

    rampStart = theMarker.time;
    rampEnd = theMarker.time + .15;
    startVal = [100,100];
    maxVal = [85,85];

    rampMid = rampStart + (rampEnd - rampStart)/2;
    if (time < rampStart || time > rampEnd){
    value
    }else if (time < rampMid){
    ease(time,rampStart,rampMid,startVal, maxVal)
    }else{
    ease(time,rampMid,rampEnd,maxVal,startVal)
    }

    P.S. I’ve omitted marker.numKeys > 0 condition since your code assumes there’s at least one marker anyway.
    And if there are several markers with the same comment (a.k.a key(name)) “Click”, this: marker.key(“Click”) – returns the first of them

  • Andrew Millen

    March 15, 2019 at 2:21 am

    That did it, thanks!

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