ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Starting a cumulative expression based on a condition

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Matt Tillman
Starting a cumulative expression based on a condition
on Mar 22, 2013 at 4:43:40 am

Hey guys,
I'm trying to get a cumulative expression to start when the position of another layer crosses its Y-Position value. In this case, start pushing layer2's X-Position once layer1's Y-Position passes it.

Here's what I have:

track = thisComp.layer("layer1").transform.position;
pos = transform.position;
accum = 0;

for(i=timeToFrames(inPoint);i<=timeToFrames(time);i++){
if (track.valueAtTime(i)[1]<=pos[1]){
accum += 0;
}else{
accum += 10;
}
}

value + [accum,0];


I can't for the life of me figure out why this code doesn't work. It seems to ignore the IF statement and accumulate from the very start.

It isn't for anything in particular, I'm just trying to get it to work as a concept.

Any help would be greatly appreciated.


Return to posts index

Roland R. Kahlenberg
Re: Starting a cumulative expression based on a condition
on Mar 22, 2013 at 6:12:33 am

Expressions do not retain values. You can pass on the value to an invisible textbox and recall the value with a textString argument. I suggest that you post your Q at the COW's AE Expressions Forum.

HTH
RoRK

Intensive mocha & AE Training in Singapore and Other Dangerous Locations

Imagineer Systems (mocha) Certified Instructor
& Adobe After Effects ACE/ACI (version 7)


Return to posts index


Darby Edelen
Re: Starting a cumulative expression based on a condition
on Mar 22, 2013 at 6:25:10 am

Try changing this line:

if (track.valueAtTime(i)[1]<=pos[1]){

to a couple of lines:

t = framesToTime(i);
if (track.valueAtTime(t)[1]<=pos[1]){

New/changed code is in bold.

Darby Edelen


Return to posts index


Matt Tillman
Re: Starting a cumulative expression based on a condition
on Mar 22, 2013 at 7:26:48 am

Thanks heaps Darby. I completely overlooked the fact that I was passing a frame value instead of time.


Return to posts index

Roland R. Kahlenberg
Re: Starting a cumulative expression based on a condition
on Mar 24, 2013 at 12:18:00 am

Good stuff Darby!

Cheers
RoRK

Intensive mocha & AE Training in Singapore and Other Dangerous Locations

Imagineer Systems (mocha) Certified Instructor
& Adobe After Effects ACE/ACI (version 7)


Return to posts index

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