Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Exit

- Home
- After Effects
- Discussions
- how to write expression in such case-7

- how to write expression in such case-7

0

/t5/after-effects-discussions/how-to-write-expression-in-such-case-7/td-p/14793500
Aug 11, 2024
Aug 11, 2024

Copy link to clipboard

Copied

Hi,

So I am playing with expressions.

To make my life more difficult I imagine Why dnt I stop the position animation at a certian point. After googling sometimes I learned that I can use 'Checkbox Expression' to control/manipulate/on-off expression. So, I did that, but dnt like the result. I want the orange circle to stop in a smooth manner not like the one I got using chekbox control. How can I apply easy ease on checkbox keyframes. If thats not possile what can I do to make the stopping velocity smooth and also I want the circle animation stops as well.

I mean the orange circle will start its animation with ''Math.sin'', it will reach a certain point and in a smooth manner and then stops.

Please guide me. 😥

TOPICS

Expressions
,
How to

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Community Expert
,
Aug 11, 2024
Aug 11, 2024

This may be what you want, but I'm not quite sure:

```
p = thisLayer.effect("Checkbox Control")("Checkbox");
t = 0;
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
if (n > 0){
for (i = 1; i <= n; i++){
if (p.key(i).value == true){
if (i < n){
t += p.key(i+1).time - p.key(i).time;
}else{
t1 = p.key(n).time;
if (n < p.numKeys){
t2 = p.key(n+1).time;
t += ease(time,t1,t2,0,t2-t1);
```

...
3
Replies
3

/t5/after-effects-discussions/how-to-write-expression-in-such-case-7/m-p/14793913#M254754
Aug 11, 2024
Aug 11, 2024

Copy link to clipboard

Copied

This may be what you want, but I'm not quite sure:

```
p = thisLayer.effect("Checkbox Control")("Checkbox");
t = 0;
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
if (n > 0){
for (i = 1; i <= n; i++){
if (p.key(i).value == true){
if (i < n){
t += p.key(i+1).time - p.key(i).time;
}else{
t1 = p.key(n).time;
if (n < p.numKeys){
t2 = p.key(n+1).time;
t += ease(time,t1,t2,0,t2-t1);
}else{
t2 = thisComp.duration;
t += easeIn(time,t1,t2,0,t2-t1);
}
}
}
}
}
}
amp = 10;
freq = 1;
y = amp*Math.sin(t*freq*Math.PI*2);
value + [0,y]
```

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/after-effects-discussions/how-to-write-expression-in-such-case-7/m-p/14793930#M254755
Aug 11, 2024
Aug 11, 2024

Copy link to clipboard

Copied

If you don't actually need the easing, then this might suffice:

```
p = thisLayer.effect("Checkbox Control")("Checkbox");
t = p.value ? time : 0;
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
if (n > 0){
t = p.key(1).value ? p.key(1).time : 0;
t += p.value ? time - p.key(n).time : 0;
for (i = 2; i <= n; i++){
t += p.key(i-1).value ? p.key(i).time - p.key(i-1).time : 0;
}
}
}
amp = 10;
freq = 1;
y = amp*Math.sin(t*freq*Math.PI*2);
value + [0,y]
```

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Suraiya A
AUTHOR

Engaged
,

LATEST
/t5/after-effects-discussions/how-to-write-expression-in-such-case-7/m-p/14794271#M254763
Aug 11, 2024
Aug 11, 2024

Copy link to clipboard

Copied

😮😮😮 I love the result. This is exactly what I wanted. The circle stops smoothly, not like before. Thank you.

Community guidelines

Resources

Troubleshooting FAQs

After Effects Community Recap

Getting started with After Effects

Copyright © 2024 Adobe. All rights reserved.