After Effects: Using a layer property as a variable in its own function

I’m trying to create a function where I can use the current value held inside a property to change itself. For example, I may want to change the opacity from 100% to 0% every 5 frames. The function would go something like

if(time%5==0){
    if(transform.opacity==100){
        transform.opacity=0;
    }else{
        transform.opacity=100;
    }
}

all contained within the opacity itself (I’m aware that I do not need to assign a value directly to opacity as I’ve done above, I could have said 0; or 100;). This code gives the warning

Object of type Layer found where a Number, Array, or Property is needed

Expression disabled.

How do I self reference a property in a function to modify itself?

Leave a Reply

Your email address will not be published. Required fields are marked *