Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Animate position according to layer marker name

  • Animate position according to layer marker name

    Posted by Eva Lepik on May 1, 2017 at 12:38 pm

    Hey,

    I would need a bit of help with an expression.
    What I’m trying to do:

    When a layer marker’s name is “UP”, the layer’s y position should animate up by comp height
    and when a layer marker’s name is “DOWN”, the layer’s y position should animate down by comp height.
    If there is no layer marker, the layer should stay on it’s current value.
    I’m assuming there will be only 1 layer marker.

    After a lot of searching in forums I think it could be possible to accomplish?
    I have tried with modifying an expression written by Dan Ebberts in the forum here, but I can’t make it work as it should.
    Testing with marker named UP or DOWN it only moves the layer down, not up.

    Could anybody check where the mistake could be? Thanks in advance!
    Eva

    I came up with this:

    moveFrames = 20;
    try{
    m = thisLayer.marker.key("UP");
    }catch(err){
    m = null;
    }
    if (m != null && time > m.time){
    t = time - m.time;
    dur = framesToTime(moveFrames);
    y = ease(t,0,dur,value[1],value[1]-height);
    [value[0],y]
    }
    else

    try{
    m = thisLayer.marker.key("DOWN");
    }catch(err){
    m = null;
    }
    if (m != null && time > m.time){
    t = time - m.time;
    dur = framesToTime(moveFrames);
    y = ease(t,0,dur,value[1],value[1]+height);
    [value[0],y]
    }
    else

    value

    Eva Lepik replied 9 years ago 2 Members · 2 Replies
  • 2 Replies
  • Steve Sierra

    May 1, 2017 at 2:31 pm

    Hi,

    I think you just forgot the curly parenthesis for your else statements :

    moveFrames = 20;
    try{
    m = thisLayer.marker.key(“UP”);
    }catch(err){
    m = null;
    }
    if (m != null && time > m.time){
    t = time – m.time;
    dur = framesToTime(moveFrames);
    y = ease(t,0,dur,value[1],value[1]-height);
    [value[0],y]
    }
    else{ //———-HERE———————–
    try{
    m = thisLayer.marker.key(“DOWN”);
    }catch(err){
    m = null;
    }
    if (m != null && time > m.time){
    t = time – m.time;
    dur = framesToTime(moveFrames);
    y = ease(t,0,dur,value[1],value[1]+height);
    [value[0],y]
    }
    else
    value
    }//———–AND HERE——————-

    Cheers !
    😉

  • Eva Lepik

    May 1, 2017 at 2:40 pm

    Thank you, Steve!

    That’s awesome :))
    I wouldn’t have found the error myself, as I ‘m just starting out with conditional expressions.

    Regards,
    Eva

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