ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Looping part of a precomp, then playing the rest

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rob Womack
Looping part of a precomp, then playing the rest
on Feb 22, 2017 at 8:56:03 pm

I have a composition that contains a precomped animation (38 frame duration) that I want to loop from the start to 12 frames until I am 26 frames from the end of the layer, then I want to play the rest.

I have my precomp in layer 1, time remapped with two keyframes (0 and 11). I have the following expression applied to the timeRemap property:


i = this;

if (i.effect("Ladder")("Checkbox") == 1) {
duration = timeToFrames (i.outPoint - i.inPoint);
layerIn = timeToFrames(i.startTime + thisComp.displayStartTime);
layerOut = layerIn + duration;
currentTime = timeToFrames(time + thisComp.displayStartTime);
trigger = timeToFrames(i.source.duration + i.source.displayStartTime - i.sourceTime(i.timeRemap.key(2).time))
remainingFrames = layerOut - currentTime;
elapsedTime = currentTime - layerIn;
if (remainingFrames > trigger) {
remapVal = elapsedTime % (timeToFrames(i.sourceTime(i.timeRemap.key(2).time)) - timeToFrames(i.sourceTime(i.timeRemap.key(1).time)))
}
else {
remapVal = timeToFrames(i.sourceTime(i.timeRemap.key(2).time)) + (trigger - remainingFrames)
}
}

framesToTime(remapVal)



Two goofy things right off - I am setting the variable i to this, and am switching back and forth from frames to time, because I copied and pasted the code from a text layer to see what was happening. When I apply the expression to the text layer's text property and make i = to the precomp layer, it works. When I apply to the precomp layer, once it hits the trigger it defaults to the duration of the precomp source layer, basically a blank screen.

There's probably a better way to do this, but the loopOut always starts from the 1st keyframe, and I want to start from the 2nd keyframe and play to the end. Any help would be appreciated.

Robert Womack
Creative Bridgekeep
http://www.CurrentMarketing.com
"Louisville's Leading Interactive Marketing Agency"


Return to posts index

Kevin Camp
Re: Looping part of a precomp, then playing the rest
on Feb 23, 2017 at 7:50:24 pm

the tricky part is your loop needs to start from 11 frames in and work backwards so that it will time correctly with the continuation...

an easier solution (expression-wise) would be to use the loopInDuration() function to loop the initial 11 frames coming into the time remapping keyframes, then play out as normal.

try this on your time-remapped layer:
loopPoint = 11; // value in frames
loopInDuration( 'cycle', framesToTime( loopPoint ) )

then you'd need to slide that layer along the timeline to where you want it to finish the animation, and then simply extend the in-point as needed.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Rob Womack
Re: Looping part of a precomp, then playing the rest
on Feb 24, 2017 at 2:29:59 pm

That worked! Thanks.

I figured I was making three lefts to take a right, but the loopIn, loopInDuration and loopOut functions confuse me, for some reason.

Robert Womack
Creative Bridgekeep
http://www.CurrentMarketing.com
"Louisville's Leading Interactive Marketing Agency"


Return to posts index

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