FORUMS: list search recent posts

Controlling layer opacity with slider - breaks when keyframed

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Henrik Wilson
Controlling layer opacity with slider - breaks when keyframed
on Nov 26, 2010 at 1:04:49 am

I have a nested pre-comp with 8 layers (basic images). I am trying to 'swap' these layers' opacity via a slider in my Main Comp, so I can display each image at certain times as my sequence proceeds.

The expression I have used is working in that it accepts index values (layer numbers) and swaps opacities as it should.

But as soon as I keyframe changes to the slider value along my time line it breaks.

Expression on each of the 8 layers in the nested pre-comp:

slider = Math.round(comp("Main Comp").layer("Material Controller").effect("Slider Control")("Slider") );
if (slider == index) 100 else 0;

Any help would be much appreciated.


Return to posts index

Dan Ebberts
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 26, 2010 at 6:02:19 am

In what way does it break? Is there an error message?

Dan



Return to posts index

Henrik Wilson
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 26, 2010 at 7:32:47 am

No error message. It's as if adding keyframes to increment the slider value (for example '2' at frame 60; '3' at frame 61) stops the expression from working. Remove these keyframes, change slider value and it works.


Return to posts index


Dan Ebberts
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 26, 2010 at 6:00:17 pm

I just tried it (by pasting in your expression) and it works exactly the way I would expect. I don't know why it doesn't work for you.

Dan



Return to posts index

Henrik Wilson
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 26, 2010 at 10:01:56 pm

Thanks Dan. I've played around some more and I think the problem relates to how deeply nested the images pre-comp is. If I place it directly in the Main Comp, keyframing does indeed work.

However I need it to nested as follows (sorry I don't know how to express nesting depth - hope this is clear):

Images Pre-Comp
V
Box-Elements Pre-Comp (2.5D box shape - images pre-comp is one side)
V
Box-N Pre-Comp (transformations collapsed)
V
Scene-N Pre-Comp
V
Main Comp

Questions are:

- Is there a way to more precisely target the images pre-comp in the expression?

- Can anyone think of a workaround or another approach to get the images pre-comp to 'swap' layers at defined times or at the in-points of scenes (of which there are 8)?

Thanks again for any help.


Return to posts index

Henrik Wilson
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 26, 2010 at 10:54:38 pm

Quick follow-up: Although I would obviously prefer to control the images pre-comp from the main comp (for ease of syncing to other things), I guess I could put the slider control directly in the images pre-comp... I will try that in the meantime.


Return to posts index


Dan Ebberts
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 26, 2010 at 10:56:11 pm

I just tried it again with 4 levels of sub comps and it still works fine. What version of AE are you using?


Dan



Return to posts index

Henrik Wilson
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 26, 2010 at 11:04:15 pm

CS3 (Mac).

It's so weird because it only stops working when keyframes are involved.


Return to posts index

Henrik Wilson
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 27, 2010 at 3:33:40 am

Update: keyframes on the slider do work _however_ it seems Main Comp assumes my image pre-comp starts at Main Comp frame 1 (when infact it first appears inside Scene-N at about the 30s mark).

Thus, to swap images the slider keyframes must be towards the beginning of the Main Comp timeline ... which seems illogical and makes syncing to Scene in-points counter-intuitive.

Note: The images pre-comp is 1m 30s long and appears (playing from its first frame at the first frame inside eight consecutive 7s long Scene pre-comps in the Main Comp.

As can probably be gathered I'm quite new to expressions and the deeper logic of time in After Effects. So any hints and tips would really be appreciated.


Return to posts index


Dan Ebberts
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 27, 2010 at 6:45:27 am

Ah, right. I think you're going to have to compensate for the time offset with something like this:

t = comp("Box-Elements Pre-Comp").layer(thisComp.name).inPoint;
slider = Math.round(comp("Main Comp").layer("Material Controller").effect("Slider Control")("Slider").valueAtTime(t + time) );
if (slider == index) 100 else 0;


Dan



Return to posts index

Henrik Wilson
Re: Controlling layer opacity with slider - breaks when keyframed
on Nov 28, 2010 at 11:36:16 pm

Thanks again Dan.

Unfortunately I couldn't get my head around your suggestion or get it to work either.

So I have resolved to sequencing the images in the images pre-comp and then manually offsetting that in time in each of my scene builds so the correct image displays at the right time ... if you get my drift.

Not ideal when it comes to re-syncing but it works.

I will re-visit your valuable help again (and get it to work)!


Return to posts index

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