Skip to main content
Participant
August 22, 2023
Answered

Fade in/out with checkbox tool

  • August 22, 2023
  • 2 replies
  • 659 views

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:

FI=effect("Fade In")("Checkbox");
FO=effect("Fade Out")("Checkbox");
Duration=effect("Duration")("Slider");
if (FI==1){
if (FI==1&&FO==1){
fadeIn=easeOut(time, inPoint, inPoint+.3, 0, 100);
fadeOut=linear(time, outPoint-Duration*.1, outPoint,0, 100)
fade=fadeIn-fadeOut;
}
fadeIn=easeOut(time, inPoint, inPoint+.3, 0, 100)} else if(FI!=1){value;}
 
if (FO==1){
if (FI==1&&FO==1){
fadeIn=easeOut(time, inPoint, inPoint+.3, 0, 100);
fadeOut=linear(time, outPoint-Duration*.1, outPoint,0, 100)
fade=fadeIn-fadeOut;
}} else if(FO!=1){value;}
 
 
This topic has been closed for replies.
Correct answer Dan Ebberts

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;
}

 

 

2 replies

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
August 22, 2023

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;
}

 

 

DeskitexAuthor
Participant
September 2, 2023

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?

Dan Ebberts
Community Expert
Community Expert
September 2, 2023

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.

Mylenium
Legend
August 22, 2023

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.