Activity › Forums › Adobe After Effects Expressions › Bring layer to front
-
Bring layer to front
Posted by Gergo Boros on March 17, 2011 at 10:10 amHi.
I have multiple layers in my project. How can I change the layers order (or bring a layer to front)? I tried to change the index of the corresponding layer to 1. Didn’t worked… I tried to put the first layer into a temporary variable, then to change the layers like
tmp = layer1, layer1 = mylayer, mylayer = tmp, but a layer can not be on the life side of an expression… So can you help me pls ;;)
Thanx a lot;)Josh Harrison replied 9 years, 8 months ago 5 Members · 13 Replies -
13 Replies
-
Dan Ebberts
March 17, 2011 at 4:06 pmYou can’t change a layer’s index with an expression. You could do it with a script using moveToBeginning(), but it wouldn’t be live.
Dan
-
Gergo Boros
March 17, 2011 at 5:39 pmSo while playing a video I can’t change the order of layers?:|
There it isn’t any way? Like applying an effect or sg like that?Okey then…
Thanx for reply;) -
Dan Ebberts
March 17, 2011 at 5:52 pmYou can change their opacity or their position in z space to make different layers visible at different times, but you can’t change their actual order in the layer stack.
Dan
-
Mark Gerstein
September 13, 2012 at 3:34 pmDan, you’re clearly the answer man (it must be a burden). I’m new to AE and am trying to wrap my head around scripts/expressions. I’ve perused your site and cut/paste countless fragments, but I still can’t figure out a problem similar to the above.
In a nutshell: I have a large collage of 2D stills arranged on a single plane (the stills are partially overlapped and often several deep). I’ve converted them to 3D objects so I can animate a camera. So far so good. Now I’d like to randomly rearrange the apparent stacking order with every frame (or maybe every 2 frames).
I understand only a script (like kinda sorta) can actually reorder layers. At this point the only thing I can think of is to make multiple comps of the animation, use the script to change each one, and THEN laboriously cut together successive frames from each comp in Premiere. Ouch!
What I need is an expression that randomly distributes all the layers in Z space (hopefully small increments that won’t create parallax) for each iteration.
Thank you in advance for any advice.
Mark
-
Dan Ebberts
September 13, 2012 at 5:01 pmYou could try something like this:
numFrames = 2;
maxZOffset = 0.5;curFr = timeToFrames(time);
seed = Math.floor(curFr/numFrames);
seedRandom(seed,true);
value + [0,0,random(-maxZOffset,maxZOffset)]You can adjust maxZOffset to get the z offset as small a possible and still work. Adjust numFrames to set how many frames each configuration is held.
Dan
-
Mark Gerstein
September 13, 2012 at 7:21 pmDan,
You’re amazing. Less than 1.5 hours after my post you respond with CODE! Speechless, and seriously indebted…I’m off to the tip jar on your site right now.2 quick questions:
1. How fine are the increments in Offset? In other words given the .5 put in how many possible positions are there between -.5 and .5?
2. There are nearly 100 layers in my comp; the chances of 2 occupying the same Offset in any given run are high. In that case will the 2 “colliding” layers appear to be in their original stacking order?Thanks again,
Mark -
Dan Ebberts
September 13, 2012 at 7:33 pmI would expect all the offsets to be different, within the precision of JavaScript floating point numbers. What I don’t know is how much a layer has to move relative to another layer at the same position to change the apparent stacking order. You’d have to run some tests to see if .5 works for 100 layers.
Dan
-
Pavol Feješ
June 18, 2016 at 6:08 pmHi Dan
You know the script that works with this expression? I need to achieve concrete layer was always the first layer in the composition.
311351b70144200278446080 -
Pavol Feješ
June 18, 2016 at 7:36 pmI’m sorry, again:
My idea is … layer (for example “Layer 1”) will always be the first layer in the composition (index 1) and if I insert another layer, that will be placed under the “Layer 1”.
Do you think it’s possible to make some script containing moveToBeginning()?
There is such a script?
Thank you
Reply to this Discussion! Login or Sign Up