ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

reference key frames in condition of expression

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
bob edwardsreference key frames in condition of expression
by on Mar 4, 2010 at 12:39:11 am

I know I've seen this in the Cow forums before but I'm not able to find it at the moment and I've been searching for an hour or so (which, admittedly, might point to my stupidity)...

I need to reference a couple of key frames in an "if"...

Here's what I have, but it's giving me errors. Help anyone?

//get the specific keyframes
timeA = transform.position.key(1);
timeB = transform.position.key(3);

//wiggle properties
a = wiggle(40, 40);
b = wiggle(20, 30);

//condition
if(time > timeA && time < timeB);
{
[a[0], b[1], value[2]];
}


As is, the code doesn't get in the way of wiggle, but wiggle happens regardless of what keyframe the CTI is at and if I add an "else" statement I get a "use of reserved word" error...

Also, when I code in PHP or JS, there are complete manuals for every function and operator that you have. Does anyone know where to find anything like that for AE Expressions?? (http://us2.php.net/manual/en/index.php is a great example)


Return to posts index

Steve RobertsRe: reference key frames in condition of expression
by on Mar 4, 2010 at 5:10:16 am

Try this, to wiggle between keys 1 and 3:

//get the specific keyframes
timeA = transform.position.key(1).time;
timeB = transform.position.key(3).time;

//wiggle properties
a = wiggle(40, 40);
b = wiggle(20, 30);

//condition
if ((time > timeA) && (time < timeB)){
[a[0], b[1], value[2]]
}
else
{
[value [0],value [1],value [2]];
}

(I had to search for if/then and time (comp methods) examples in the help, and insert the else to return the "normal" values. Been a while ...)



Return to posts index

bob edwardsRe: reference key frames in condition of expression
by on Mar 4, 2010 at 5:52:54 am

That worked perfect! Thanks!
It always seams that it's syntax that kills...

Also, I found this in answer to my last question:
http://www.adobe.com/products/aftereffects/pdfs/aftereffectscs3_scripting_g...


Return to posts index


Steve RobertsRe: reference key frames in condition of expression
by on Mar 4, 2010 at 1:39:32 pm

Nice link, thanks. I'd check to see if there are any changes in syntax between CS3 and CS4.

I forget the programming term for this, but I created a text layer and tied its source to the time of the keyframes as indicated in your expression to make a thing that displays the value of a line in the expression. When it didn't return the time of the keyframe, I realized that something was missing, so I added "time" to your keyframe time-finders, first at the beginning, then at the end (duh).

After that, it was the "else" and brackets that needed to be fixed.



Return to posts index

Todd KoprivaRe: reference key frames in condition of expression
by on Mar 4, 2010 at 2:46:31 pm

regarding a reference document for expressions:

"Expression language reference"

You should also check out "Expression examples" and "Expression basics".

The document that you linked to in an earlier pot on this thread is for After Effects scripting, which is a totally different thing. See this page.

---------------------------------------------------------------------------------------------------------
Todd Kopriva, Adobe Systems Incorporated
putting the 'T' back in 'RTFM' : After Effects Help on the Web
---------------------------------------------------------------------------------------------------------
If a page of After Effects Help answers your question, please consider rating it. If you have a tip, technique, or link to share---or if there is something that you'd like to see added or improved---please leave a comment.


Return to posts index

bob edwardsRe: reference key frames in condition of expression
by on Mar 4, 2010 at 6:22:48 pm

Todd, those were great - Thanks!!


Return to posts index


Darby EdelenRe: reference key frames in condition of expression
by on Mar 11, 2010 at 5:05:18 am

[bob edwards] "Also, when I code in PHP or JS, there are complete manuals for every function and operator that you have. Does anyone know where to find anything like that for AE Expressions??"

AE Expressions use JavaScript. This is especially handy for things like parsing strings as all of the standard JavaScript functions are accessible in AE expressions.

Also I wanted to recommend that instead of just turning on the wiggle, you ease into it over a period of time:


t = 0.5 //time to ease into wiggle over

//get the specific keyframes
timeA = transform.position.key(1).time;
timeB = transform.position.key(3).time;

//wiggle properties
a = wiggle(40, 40);
b = wiggle(20, 30);

wiggled = [a[0], b[1], value[2]]; //the value with a wiggle, if none of the following conditions are met then this is the returned value


//conditionals
if((time <= timeA)||(time >= timeB)) value; //if the time is outside of the range we're concerned with, return the actual value

else if(time < timeA + t) linear(time, timeA, timeA + t, value, wiggled); //if we're in the range of time and haven't reached the end of the 'ease in' then interpolate from the actual value to the wiggled value

else if(time > timeB - t) linear(time, timeB - t, timeB, wiggled, value); //if we're in the range of time and have passed the beginning of the 'ease out' then interpolate from the wiggled value to the actual value


Should work pretty well. Although you may just want the wiggle to flip on. Still, linear() is a great function and everyone should use it more (so says I).

Darby Edelen


Return to posts index

bob edwardsRe: reference key frames in condition of expression
by on Mar 11, 2010 at 6:17:34 am

Thanks!
Very cool and helpful!

I would normally ease in to wiggle (that's a great call) as artistic decision, but I'm just animating a hand writing on text quickly (and it's a lot of text) so I'm using simple masks, a stock hand photo and a small amount of wiggle along the very simple motion path.

This is the second in a run of two similar videos for a client (



) and if I had a larger budget, I'd use stroke and animate the motion paths to match perfectly. interesting tip: you can create the text in Adobe Illustrator, convert it to a vector and copy and paste the paths into after effects as keyframes in a property (like position). This looked really cool, but would take way to much to make changes and the client is particular about text for good reasons.

Thanks again for the code - I'll play with linear() some more!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]