<p>You need to provide a bit more detail, but if you want an expression to happen only when a slider is above a certain value you can use <code>if(something &gt; somethingElse){do stuff here}</code>. </p>

<p>To time an animation so that it starts at that point is more tricky. Expressions can't store variables; they just evaluate each frame. So to find how far through the action the animation should be you'd have to calculate the first frame at which the property went above the threshold. You can do this with a loop:</p>

<pre class="lang-js prettyprint-override"><code>var propertyToWatch = thisComp.layer("someLayer").someProperty;
var threshold = 12345;
if (propertyToWatch &gt; threshold){ // above the threshold, time to do stuff
    var t = 0;
    // now search for the time when the property went above the threshold
    while (t &lt;= thisComp.duration &amp;&amp; propertyToWatch.valueAtTime(t) &lt; threshold){
        t += thisComp.frameDuration; //add one frame
    }
    // t now equals the time when the property went above the threshold.
    // so the animation's relative age is time - t
    var animationAge = time - t;
    //do the animation stuff here, using animationAge as the time constant
}
</code></pre>

<p>This expression will get progressively slower to calculate as the sequence gets older, because the inner <code>while</code> loop has to be evaluated for each preceding frame. But usually only a problem if you have lots and lots of layers with this kind of expression, or your comp is half an hour long.</p>

CC BY-SA 4.0
2020-01-26T00:25:59.667Z
2020-01-26T00:25:59.667Z
stib
<p>I'll try to explain a little bit more in-depth, I'm making a set of animations for a website and the client essentially wants a preview of how each element reacts to each other as you're scrolling down the page. I have no experience with website development and that is fine for this job, as all im doing is setting up an interactive preview for the developer. </p>

<p>So far I've parented all the elements to a Null object and the Y position value of that null to slider controls and so far so good.</p>

<p>Now where I'm lost or in fact, confused if it's even possible within AE is to set up each animation element to start its sequence once I scroll the slider to a specific value? I'm not too familiar with expressions so any help will be appreciated. </p>

<p>If you need me to explain in more detail please do ask, hopefully I've tried to make it clear for what I'm asking  </p>

<after-effects><animation><after-effects-expressions>
How to link the start and pause of an animation to a specific height from a null object?
Lour
# How to link the start and pause of an animation to a specific height from a null object?

(Asked by: username_0 on 2020-01-25)

I'll try to explain a little bit more in-depth, I'm making a set of animations for a website and the client essentially wants a preview of how each element reacts to each other as you're scrolling down the page. I have no experience with website development and that is fine for this job, as all im doing is setting up an interactive preview for the developer.

So far I've parented all the elements to a Null object and the Y position value of that null to slider controls and so far so good.

Now where I'm lost or in fact, confused if it's even possible within AE is to set up each animation element to start its sequence once I scroll the slider to a specific value? I'm not too familiar with expressions so any help will be appreciated.

If you need me to explain in more detail please do ask, hopefully I've tried to make it clear for what I'm asking

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


---

## 1 answers

### Answer by username_1 on 2020-01-26. Score: 1

You need to provide a bit more detail, but if you want an expression to happen only when a slider is above a certain value you can use if(something > somethingElse){do stuff here}. 
To time an animation so that it starts at that point is more tricky. Expressions can't store variables; they just evaluate each frame. So to find how far through the action the animation should be you'd have to calculate the first frame at which the property went above the threshold. You can do this with a loop:
var propertyToWatch = thisComp.layer("someLayer").someProperty;
var threshold = 12345;
if (propertyToWatch > threshold){ // above the threshold, time to do stuff
    var t = 0;
    // now search for the time when the property went above the threshold
    while (t <= thisComp.duration && propertyToWatch.valueAtTime(t) < threshold){
        t += thisComp.frameDuration; //add one frame
    }
    // t now equals the time when the property went above the threshold.
    // so the animation's relative age is time - t
    var animationAge = time - t;
    //do the animation stuff here, using animationAge as the time constant
}

This expression will get progressively slower to calculate as the sequence gets older, because the inner while loop has to be evaluated for each preceding frame. But usually only a problem if you have lots and lots of layers with this kind of expression, or your comp is half an hour long.


---

