Skip to main content
Participant
February 2, 2023
Question

Use Checkbox to control the visibility of a layer after a certain time

  • February 2, 2023
  • 1 reply
  • 405 views

Hey,

I'm useing the checkbox to control the visibility of a layer by using the expression in my project. The expression is below:

 

if(comp("WAR_MASTER").layer("PLAYER_IMAGE_NUMBER_CTRL").effect("CHECK IF USE TWO IMAGES")("Checkbox")==1) 0 else 100

 

It worked well, and I just wonder whether it is possbile to make the opacity of this layer change only after a certain time (says after 1 sec) once I clickthe Checkbox?

 

Thanks very much.

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
February 2, 2023

Something like this maybe:

cb = comp("WAR_MASTER").layer("PLAYER_IMAGE_NUMBER_CTRL").effect("CHECK IF USE TWO IMAGES")("Checkbox");
delay = 1.0;
if (cb.numKeys > 0){
  n = cb.nearestKey(time).index;
  if (time < cb.key(n).time) n--;
  if (n > 0){
    if (cb.key(n).value){
      t = time - cb.key(n).time;
      t > delay ? 100 : 0;
    }else{
      0;
    }
  }else{
    0;
  }
}else{
  cb.value ? 100: 0;
}
Participant
February 3, 2023

Thanks for your help. It seems not working on my project, but its' very inspiring.

I finnaly figured out another way to achieve what I'm after by useing a slider control with two key frames.

 

The two key frames are toggle hold keys on the opacity property, the first is 100% and the second is 0%, and the slider control is set on a null layer called "PLAYER_IMAGE_NUMBER_CTRL". The expression part is this:

 

a = thisComp.layer("PLAYER_IMAGE_NUMBER_CTRL").effect("Slider Control")("Slider").value;
if (a == 1)
{key(thisComp.layer("PLAYER_IMAGE_NUMBER_CTRL").effect("Slider Control")("Slider").value);}
else
{valueAtTime(time);}