Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: ForumAE BasicsAE ExpressionsTutorialsArticlesPodcastsMotion GraphicsTrainingCinema 4D

Re: auto scaling keyframes

Cow Forums : Adobe After Effects Expressions
VIEW POSTS   •   ADD A NEW POST   •   SEARCH   •   CHANGE FORUM
Return to Posts Index   •   Read Entire Thread   •   Reply To This Post


cow
Re: auto scaling keyframes
by Filip Vandueren on Jun 25, 2008 at 12:59:07 pm

Yes, I get it now:


l=thisComp.layer("control");

if (l.position.numKeys>=4) {
t2=l.position.key(2).time- l.inPoint;
t3=l.position.key(3).time- l.outPoint;

if (inPoint+t2>=time) {
TT=linear(time,inPoint,inPoint+t2,l.inPoint,l.inPoint+t2);
} else if (outPoint+t3>=time) {
TT=linear(time,inPoint+t2,outPoint+t3, l.inPoint+t2, l.outPoint+t3);
} else {
TT=linear(time,outPoint+t3,outPoint,l.outPoint+t3,l.outPoint);
}

l.position.valueAtTime(TT);
} else {
value;
}


OK this looks a lot more complex, but it's not really:

first check if there are 4 position keyframes, otherwise we would get errors and this stuff wouldn't work.
There are 3fases:
-from the layer's inPoint to the 2nd keyframe,
-from 2nd to 3rd keyframe
-from 3rd keyframe to the layer's outPoint

so there are 3 if/then's to check in which stage of time we are now,
the correct corresponding time TT on the controlLayer is calculated with linear(), then we sample the value at time TT.

I suppose Keyframe 2 and 3 are identical ? A move in, and Move out, but this expression will work if they're not.
The expression will not work correctly if the new Layer has a length that's shorter than the moveIn + the Move Out (in your case 24 frames)



Return to Posts Index   •   Read Entire Thread   •   Reply To This Post


Current Message Thread:




Note: If you are a registered user and you do not see your name and email in the two respective fields above, you may reset your account cookies by clicking here. Your post will not be accepted if the name and email provided above are not currently registered in our database.

Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message   Entire Thread   None  


Message                Add Bold Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this buttonAdd Italic Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this buttonAdd Underline Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this buttonAdd Image Link Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this buttonAdd URL Link Tag To Message (JavaScript required)

To put any item inside this tag:

1. Highlight the desired text
2.Click this button

Note: The following characters are HTML command characters, and may cause parts of your post to disappear, if not used correctly: < > &. To include any portion of the post in your response, highlight the desired text and hit the "Q" key. For more on how to post, click here.


Please post Expressions Code in the box below:


Add your message signature


 


Note: By clicking "Post Direct" button above, you are agreeing to the Creative Cow's Code of Conduct.



FORUMSTUTORIALSMAGAZINEDVDsBOOKSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]