Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Starting a cumulative expression based on a condition

  • Starting a cumulative expression based on a condition

    Posted by Matt Tillman on March 22, 2013 at 4:43 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.

    Roland R. kahlenberg replied 13 years, 1 month ago 3 Members · 4 Replies
  • 4 Replies
  • Roland R. kahlenberg

    March 22, 2013 at 6:12 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)

  • Darby Edelen

    March 22, 2013 at 6:25 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

  • Matt Tillman

    March 22, 2013 at 7:26 am

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

  • Roland R. kahlenberg

    March 24, 2013 at 12:18 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)

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy