Activity › Forums › Adobe After Effects Expressions › changing opacity at specific time
-
changing opacity at specific time
Posted by Yafes Sahin on February 12, 2010 at 9:29 pmHi guys,
i would like to change the opacity of a specific layer, every 0,5 seconds. So my Idea was to do that:
if(time % 0.5 == 0)
transform.opacity = 0;
else
transform.opacity =100;but nothing happens…. i don’t know why, but it seems, that AE doesnt like modulus.
Maybe someone can give me an advice.
Yafes Sahin replied 16 years, 2 months ago 2 Members · 5 Replies -
5 Replies
-
Kevin Camp
February 12, 2010 at 10:40 pmhow about something like this:
Math.round(time%1)*100
Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW -
Yafes Sahin
February 12, 2010 at 10:54 pmreally nice,
but the 100 is not needed at the end. What i am not understanding. I have a movie with 15fps. That means time = 1 when i am at frame 15.
When i am at frame 1 it means in seconds 0,066666
The reason i am asking, what when i wand every 4 (3,75) frame changing the opacity, so that i get 250ms?
it wont work with Math.round(time%0.4)
thank you
-
Kevin Camp
February 12, 2010 at 11:42 pmi don’t think you can use a decimal with a modulus… time%0.4 is like stay you want the remainder of time*4… there is no remainder in that equation.
try converting time from seconds to frames. in later versions of ae you can use timeToFrames(). in earlier version you could use time/thisComp.frameDuration
maybe an expression like this:
if(timeToFrames(time)%8<4) 0 else 100
Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW -
Yafes Sahin
February 13, 2010 at 6:49 amThanks mate,
its working fine,
very clever one:
if(timeToFrames(time)%8<4)i would have done this in this way:
if(timeToFrames(time)%4==0)
and would forget, that than the first frame (time= 0) woul also give true backFor me its done . Next i will try to change the Modulus Value, so that the time between the switches are getting closer and closer 😉
Thank you again so much for your help, and insane fast replies!
-
Yafes Sahin
February 20, 2010 at 12:07 pmHi @ all,
i am now here to add some changes to my script, but i have new questions.
var moduloConst = 32;
if(timeToFrames(time)%moduloConst1) It’s weired, adding
moduloConst = moduloConst/2
lets transform.opacity gets filled with the “moduloConst” value. (In this case 32)would be nice if someone could give me a hint.
Reply to this Discussion! Login or Sign Up