Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change expression at a certain point in timeline

  • Change expression at a certain point in timeline

    Posted by Tobias Gommer on June 15, 2009 at 1:52 pm

    Hi world,

    As a flashdesigner I have some problem converting to After Effects as it comes to timeline animation by expressions.
    I have a set of expressions doing some stuff (lets say: a text field counts up from zero to ten.) after lets say 6seconds I would like to let it count back to 1, basically using the same script..

    In flash I would add a keyframe, add a new actionscript snippet and show it to my boss and he would end up giving me a raise! I want the raise, you know? 😉

    So in general: how do I perform some action based on expressions later on in time? Am I going to end up eventually with n amount of code lines in the first frame (actually I suppose it’s not realy on the first frame, but on the layer…)

    Dan Ebberts replied 17 years, 1 month ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    June 15, 2009 at 5:01 pm

    You can do it like this:

    if (time < 6){ // interesting code here }else{ // different code here } Or, you can execute different code based on proximity in time to layer markers or keyframes. In any case, you're correct that all the code snippets will be in the same expression. Dan

  • Tobias Gommer

    June 16, 2009 at 8:05 am

    Hi Dan, thanks for your time! I went along with “time” and I ended up with this the following: I thought It was going to count up to 10.000 and after 6 seconds it would count down to 1000. Cleary I’m wrong because the output it undefined. (this is al happening at a textlayer)

    if (time <6){
    doCounter(0,10000,5);
    }
    else if (time > 6){
    doCounter(10000,1000,5);
    }

    function doCounter(startCount,endCount,countDur){
    s = "" + Math.round(linear(time,0,countDur,startCount,endCount));

    if (s.length > 3){
    s.substr(0, s.length -3) + "." + s.substr(-3);
    }else{
    s
    }
    }

  • Tobias Gommer

    June 16, 2009 at 11:26 am

    Okay I have been playing with this and I found out the 2nd paramater in the linear function is actually some sort of delay. My problem turned out the 2nd function did run, except it showed the endCounter result. When the expression is fired, the counter is already counting at the same time as the first counter. So when the movie reaches 6seconds it has already been there in the background. So I came up with this
    go = 0;
    if (time < 7){ doCounter(0,10000,5); } if(time >= 7){
    doCounter2(10000,1000,12);
    }

    function doCounter(startCount,endCount,countDur){
    s = "" + Math.round(linear(time,0,countDur,startCount,endCount));
    return s;
    }

    function doCounter2(startCount,endCount,countDur){
    s = "" + Math.round(linear(time,6,countDur,startCount,endCount));
    return s;
    }

    I couldn´t find some sort of reference list of all the expressions, although I found Dan´s site and some others, but there´s no index or something. Thanks for reading this.

  • Dan Ebberts

    June 16, 2009 at 1:36 pm

    You could consolidate your code a little by addining another parameter to your function, like this:

    t1 = 5;
    t2 = 7;
    t3 = 12;

    if (time < t1){ doCounter(0,0,10000,t1); }else if (time < t2){ 10000 }else{ doCounter(t2,10000,1000,t3-t2); } function doCounter(startT, startCount,endCount,countDur){ s = "" + Math.round(linear(time,startT,startT+countDur,startCount,endCount)); return s; } The section on interpolation methods in Adobe's Expression Reference might be helpful to you: https://help.adobe.com/en_US/AfterEffects/9.0/WS3878526689cb91655866c1103906c6dea-7a06a.html

    Dan

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