<p>If you look at the part where you have 
</p>

<pre><code>if (headIntro==false){
    y =linear(time,t1,t2,v2,v2); //this is calculated first
}

if (headOutro==false){
    y =linear(time,t3,t4,v3,v3); //this is calculated next, overwriting previous value
}  
</code></pre>

<p>when <code>headOutro == false</code> is true, the value for y will be calculated using the value returned by the second <code>linear</code> expression, so no matter what it was previously calculated to be it will always return <code>y = linear(time, t3,t4,v3,v3);</code>.</p>

<p>change it to</p>

<pre><code>if (headIntro==false &amp;&amp; time &lt; t2){
    y =linear(time,t1,t2,v2,v2);
}

if (headOutro==false &amp;&amp; time &gt; t3){
    y =linear(time,t3,t4,v3,v3);
}  
</code></pre>

<p>so now the <code>linear</code> expressions will only be calculated when the time is in the intro or outro sections respectively.</p>

CC BY-SA 4.0
2019-08-13T09:32:22.143Z
Oh wow, that was simpler than I thought. Thank you stib!
Steffen
CC BY-SA 4.0
2019-08-13T08:33:35.227Z
2019-08-13T08:33:35.227Z
stib
<p>I have a position animation with four keyframes, two for a intro, two for a outro. Also I have a Master where you have two checkboxes "Intro" and "Outro". 
The idea is to override the keyframe values so that there won't be any intro animation when the checkbox for it isn't checked (same for outro). 
Sadly I only can override all values, so when I uncheck one of the checkboxes, there is no animation anymore. How can I change only the value inbetween the keyframes I need?</p>

<pre><code>var x=thisProperty[0]; 
var y=thisProperty[1];
var headIntro=thisComp.layer("MASTER").effect("HEADLINE | Intro")(1);  
var headOutro=thisComp.layer("MASTER").effect("HEADLINE | Outro")(1);  

if (numKeys &gt; 3){

    var t1 = key(1).time;
    var t2 = key(2).time;
    var t3 = key(3).time;
    var t4 = key(4).time;

    var v1 = key(1).value[1];
    var v2 = key(2).value[1];
    var v3 = key(3).value[1];
    var v4 = key(4).value[1];


    if (headIntro==false){
        y =linear(time,t1,t2,v2,v2);
    }

    if (headOutro==false){
        y =linear(time,t3,t4,v3,v3);
    }  
}
[x,y]
</code></pre>

<p>Thanks for the help</p>

<after-effects><after-effects-expressions><keyframes>
AE Keyframe Control through checkboxes
Steffen
# AE Keyframe Control through checkboxes

(Asked by: username_0 on 2019-08-12)

I have a position animation with four keyframes, two for a intro, two for a outro. Also I have a Master where you have two checkboxes "Intro" and "Outro". 
The idea is to override the keyframe values so that there won't be any intro animation when the checkbox for it isn't checked (same for outro). 
Sadly I only can override all values, so when I uncheck one of the checkboxes, there is no animation anymore. How can I change only the value inbetween the keyframes I need?
var x=thisProperty[0]; 
var y=thisProperty[1];
var headIntro=thisComp.layer("MASTER").effect("HEADLINE | Intro")(1);  
var headOutro=thisComp.layer("MASTER").effect("HEADLINE | Outro")(1);  

if (numKeys > 3){

    var t1 = key(1).time;
    var t2 = key(2).time;
    var t3 = key(3).time;
    var t4 = key(4).time;

    var v1 = key(1).value[1];
    var v2 = key(2).value[1];
    var v3 = key(3).value[1];
    var v4 = key(4).value[1];


    if (headIntro==false){
        y =linear(time,t1,t2,v2,v2);
    }

    if (headOutro==false){
        y =linear(time,t3,t4,v3,v3);
    }  
}
[x,y]

Thanks for the help

**Tags:** after-effects, after-effects-expressions, keyframes


---

## 1 answers

### Answer by username_1 on 2019-08-13. Score: 0 | Accepted answer

If you look at the part where you have 

if (headIntro==false){
    y =linear(time,t1,t2,v2,v2); //this is calculated first
}

if (headOutro==false){
    y =linear(time,t3,t4,v3,v3); //this is calculated next, overwriting previous value
}  

when headOutro == false is true, the value for y will be calculated using the value returned by the second linear expression, so no matter what it was previously calculated to be it will always return y = linear(time, t3,t4,v3,v3);.
change it to
if (headIntro==false && time < t2){
    y =linear(time,t1,t2,v2,v2);
}

if (headOutro==false && time > t3){
    y =linear(time,t3,t4,v3,v3);
}  

so now the linear expressions will only be calculated when the time is in the intro or outro sections respectively.

> **Comments:**
> **username_0**: Oh wow, that was simpler than I thought. Thank you username_1!  

---

