ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression stops working once I add keyframes

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dean Morgan
Expression stops working once I add keyframes
on May 21, 2014 at 9:45:55 am
Last Edited By Dean Morgan on May 21, 2014 at 9:48:03 am

I'll try my best to explain what I am trying to achieve, how I have set about it and the problem I am having but if any more info is needed please ask.

Basically I have a selection of images in a subcomp that I want to be able to switch on and off at a time of my choosing and in any order I select.

I added all of the images into a subcomp, I set the length of this to a single frame.

In my main comp I enabled time remapping on the subcomp and stretched it to the duration of the main comp.

On each of the layers within the subcomp I added an expression that controls the opacity of the layer from a checkbox on a control layer in the main comp.

The expression I used was the following:

if (comp("MAIN").layer("CONTROLS").effect("IMAGE1")("Checkbox")==1) {100}
else {value}


Now everything seems to work fine, when I check the box the corresponding image appears. I can select as many as I like in any order I like and it works how I imagined it should do.

The problem starts as soon as I add a keyframe to any of the checkboxes. The value for the checkbox changes still, but the state of the image no longer changes.

I'm not sure what I am doing wrong and I know it could be something simple but I cannot for the life of me find out what the problem is.

Any help would be greatly appreciated.


Return to posts index

Dan Ebberts
Re: Expression stops working once I add keyframes
on May 21, 2014 at 5:48:39 pm

That can happen if the start time of the time remapped precomp layer isn't zero in the main comp. See if this helps:

C = comp("MAIN");
ctrl = C.layer("CONTROLS").effect("IMAGE1")("Checkbox");
L = C.layer(thisComp.name);
if (ctrl.valueAtTime(time+L.startTime)==1) 100 else value


Dan



Return to posts index

Dean Morgan
Re: Expression stops working once I add keyframes
on May 22, 2014 at 10:23:02 am

I thought that might be the case so I checked that the start time matches up, everything seemed fine so just to be safe I removed the time mapped precomp and then added it again and set up the time remapping from scratch.

Had no joy with that though so I tried your expression and again I had no joy with that also.

However if I go into the precomp and make that the same length as the comp that contains it, and remove the time remapping from it everything works fine.

I understand that I could use this as a workaround but I have come across this problem & workaround before and I could really do with figuring out exactly what it is I am doing wrong so I can avoid it happening in future.

I can provide screenshots, or even upload the project file if it will help someone to help me figure out what is going wrong.

Thanks for your reply though Dan, it is appreciated.


Return to posts index


Chris Voelz
Re: Expression stops working once I add keyframes
on Mar 13, 2019 at 4:29:05 pm

Hi Dan, I think I may be having the same problem and I am just unsure how to apply your fix.

I am using a slider control to control the scale of an object on the x axis. The comp where the asset being controlled lives is not the same length as the main comp. The expression works great when there are no keyframes. As soon as I add keyframes to animate the scale the expression no longer updates the value of the slider.

temp = comp("Compliance Bulletin").layer("Time Left").effect("Time Left Control")("Slider");
[temp, 100];


Return to posts index

Dan Ebberts
Re: Expression stops working once I add keyframes
on Mar 13, 2019 at 4:42:09 pm

See if this helps:

C = comp("Compliance Bulletin");
temp = C.layer("Time Left").effect("Time Left Control")("Slider");
L = C.layer(thisComp.name);
[temp.valueAtTime(time+L.startTime), 100];


Dan



Return to posts index

Chris Voelz
Re: Expression stops working once I add keyframes
on Mar 13, 2019 at 5:14:37 pm

Thanks Dan!

So this is essentially just looking at the time of the main comp and adding that before the pre-comp so they align?


Return to posts index


Dan Ebberts
Re: Expression stops working once I add keyframes
on Mar 13, 2019 at 5:19:04 pm

It compensates for the non-zero start time of the precomp layer in the main comp.


Dan



Return to posts index

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