Copy link to clipboard
Copied
Please help me create objects to fade in and fade out with the checkbox tool. So I want when the checkbox turns on it will auto fade and vice versa. Here's my code for reference:
It appears from your code that you only use the Duration slider for fade out, and I'm not sure about the .1 multiplier, but I think I'd structure it like this:
FI = effect("Fade In")("Checkbox").value;
FO=effect("Fade Out")("Checkbox").value;
Duration=effect("Duration")("Slider");
if (time < (inPoint + outPoint)/2){
FI ? ease(time,inPoint,inPoint+.3,0,100) : value;
}else{
FO ? ease(time,outPoint - Duration*.1,outPoint,100,0) : value;
}
Copy link to clipboard
Copied
Your rules don't make any sense and thus disable one another. You need to nest them correctly (pseudo code):
if (FI == 1)
{
if (FO == 1)
{}
else
{}
}
else
{}
Nothing more required. You are making this too complicated.
Copy link to clipboard
Copied
It appears from your code that you only use the Duration slider for fade out, and I'm not sure about the .1 multiplier, but I think I'd structure it like this:
FI = effect("Fade In")("Checkbox").value;
FO=effect("Fade Out")("Checkbox").value;
Duration=effect("Duration")("Slider");
if (time < (inPoint + outPoint)/2){
FI ? ease(time,inPoint,inPoint+.3,0,100) : value;
}else{
FO ? ease(time,outPoint - Duration*.1,outPoint,100,0) : value;
}
Copy link to clipboard
Copied
Thank you I'm still learning so I didn't know that conditional if can be used with time, by the way, why should the 'checkbox' be added with .value? what's the difference?
Copy link to clipboard
Copied
Usually, when you set a variable equal to a control (like a slider or a checkbox) and later reference that variable in the expression, the expression engine assumes you want the control's value, but sometimes it assumes you're referring the object itself, not its value. I don't remember if that was the case here, or if I did it just to be safe. You could try leaving out .value and see if the expression stops working.
Copy link to clipboard
Copied
just one more question, can you explain about this "FI? ease(time,inPoint,inPoint+.3,0,100) : value;" I thought conditionals should always have a condition (like FI=1 blablabla) so I was quite surprised by "FI?", that's why my code is quite messy.
Copy link to clipboard
Copied
? followed by : is JavaScript's conditional operator. It's just a shorthand way of putting a short if/else on a single line;
FI ? ease(time,inPoint,inPoint+.3,0,100) : value;
is the same as
if (FI) { ease(time,inPoint,inPoint+.3,0,100) }else{ value };
Copy link to clipboard
Copied
Thanks a lot sir, now I understand the logic 😉
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more