Another newbie question.
Tried this expression on a layers opacity:
d = Math.abs(time -transform.position.nearestKey(time).time);
easeOut(d, 100, 0)
The idea was to make the layers opacity go from 100% to 0 on every keyframe.
What actually happens is the opacity goes down to 36% in the middle between two keyframes, then goes up to 100 again.
Found this: http://library.creativecow.net/articles/ebberts_dan/ae6_exp.php
So if I knew that the keyframes where 1 sec apart this would do the trick
fade = .99;
hold =.01;;
t = time%(fade + hold + fade);
if(t < fade){
linear(t,0,fade,100,0)
}else if (t < (fade + hold)){
100
}else{
linear(t,fade+hold,fade+hold+fade,100,0)
}
Now I just need to figure out the math for calculating the time between keyframes
This works good enough, but I would like to find a better solution for the first keyfram.
if(transform.position.numKeys>0);
{
n =transform.position.nearestKey(time).index;
if(n>1){
p = transform.position.key(n-1);
fade = transform.position.key(n).time - p.time;
hold =.01;;
t = time%(fade + hold + fade);
if(t < fade){
linear(t,0,fade,100,0)
}else if (t < (fade + hold)){
100
}else{
linear(t,fade+hold,fade+hold+fade,100,0)}
}
else {value}
}
Thank you Dan, that was much more accurat then the solution I found. My code actually worked quite well in a simple test, but in a more complex test there were a lot of flickering. Your code works perfect for all but the very first keyframe.
http://screencast.com/t/rPZbB5ljjZbl
Please have a look at this short video and notice the flickering in the beginning. Any thoughts?
North America
Europe, Middle East and Africa
Asia Pacific