Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Increase number/content of text when passing layer marker?

  • Increase number/content of text when passing layer marker?

    Posted by Lennert Schrader on December 8, 2011 at 5:56 pm

    Hi,

    I need a textlayer to increase its content by 1 on each layer marker.

    Example:
    Lets say my textlayer says “0”.
    After my time passed a layer marker, my text should now say “1”.
    And after passing another layer marker it should say “2”.
    And so on.

    I am not so familiar with expressions, so I don’t know what I need to write and that’s why I am asking here.
    But I guess it would look something like this (roughly):

    myText = 0;
    text.sourceText = myText;
    onLayerMarker: myText++

    Does anyone know how to do this correctly?

    Any help would be really appreciated! =)

    Thanks,
    Lennert

    David Cabestany replied 9 years, 11 months ago 3 Members · 5 Replies
  • 5 Replies
  • Lennert Schrader

    December 8, 2011 at 6:15 pm

    I found the solution!!!
    I found it in this forum – sorry for not looking well enough before!

    If anyone comes by, below is the expression I ended up using.

    I added the last line of code, to change the initial starting number of my text layer (2853).
    The number will begin to change from the second layer marker on.

    Thanks to Walter Soyka – I used his expression from here:
    https://forums.creativecow.net/thread/2/989308

    m = thisLayer.marker;
    i = m.nearestKey(time).index;

    if (m.nearestKey(time).time > time){ i--;}
    if (i < 1) { i = 1};
    i--;

    text.sourceText = i+2853

  • Kevin Camp

    December 8, 2011 at 6:26 pm

    glad you found a solution… and as with most things in ae, there are many ways to do the same thing… another method would be to use the marker’s index value to increase the values:

    n = marker.nearestKey(time).index;
    if (marker.key(n).time >= time) n-1 else n;

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • David Cabestany

    September 16, 2016 at 8:51 pm

    Hey Kevin, this expression does exactly what I need, except that it jumps in whole increments, i.e. goes straight from 2 to 3 and I need it to go 2, 2.01, 2.02, etc all the way to 3 and so on. Basically add a linear expression into yours; but I’m not very clear on where to integrate the missing code, do you mind helping with that?

    Thanks in advance.
    D.

  • David Cabestany

    September 16, 2016 at 8:55 pm

    By the way, I’m not using it to drive text but increasing the value of a parameter at irregular intervals. I started using loopOut (“offset”) but I need the time in between to be different each time.

  • David Cabestany

    September 17, 2016 at 12:03 am

    I tried something like this, but it’s not working. Anyone?

    n = marker.nearestKey(time).index;
    if (marker.key(n).time >= time)
    n-1
    else
    linear(time,0,1,n-1,n);

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