Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Get the time value when a variable changes.

  • Get the time value when a variable changes.

    Posted by Mateo Mazzini on February 4, 2016 at 8:24 pm

    Hi first of all excuse me for my english it is not my native tongue.
    The expression I pasted below must be applied to the time remap property. so you can trigger the animation with this expression.
    I have two problems with this expression, the first one is im using an IF to trigger the animation, but the object called ELEMENT passes through the sampling area in about 10 frames, then leaves it, and the alpha variable goes back to a value of 0, and so the IF changes and the animation get stopped. Is there a way to keep the animation going?.
    second problem, once the IF starts I use TIME to control a LINEAR, but the value of TIME is the value of the composition´s time, and I need to generate a variable that stores the TIME minus the time at the moment the IF changed and triggered the animation. Is there a way to accomplish this?

    Thank you very much!

    var alpha=thisComp.layer("ELEMENT").sampleImage(thisComp.layer("LAYERBASE").transform.position,[300,300])[3];
    if(alpha>0){
    linear(time,0,120,key(1),key(2))}

    Matz

    Kalleheikki Kannisto replied 10 years, 2 months ago 3 Members · 2 Replies
  • 2 Replies
  • Eduardo Oliveira

    February 28, 2016 at 12:08 pm

    Unfortunately at the moment after effects is unable to store variables. you can sample a value from the past, but not store values for posterior use ( the expression will re-run every frame, clearing any stored values again)
    you can, however, use the key(n).time as a switch.. or the element position value as a threshold

  • Kalleheikki Kannisto

    March 1, 2016 at 7:52 am

    Why do you want to do it with an expression if it happens only once? Why not do it with a keyframe instead?

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