Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions if/else expression

  • if/else expression

    Posted by Jan Heybowitz on October 22, 2010 at 10:15 pm

    hi there,
    i’m totally new into expressions. just thought that can’t be so tough but now i see it won’t work out like i thought.

    i’m trying to scale up a layer over time till 100% when this value is reached i want it to scale down to 0% and up again.. in a loop.

    hope you guys can help me. =)

    if (transform.scale < 100) transform.scale *0.5*time else if (transform.scale > 100) transform.scale *0.5*-time else transform.scale *0.5*time

    Hannes Paulsson replied 15 years, 6 months ago 4 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    October 22, 2010 at 10:38 pm

    I think you’ve run into one of the features of expressions that trips up a lot of rookies. When an expression refers to the property housing the expression (scale in this case), what it gets is the pre-expression value, not (as you might expect) a previously calculated value. The expression has no access to results it calculated previously.

    However, if you can describe exactly what you want to happen in terms of times and scale values, it’s not hard to set up the kind of loop you’re talking about.

    Dan

  • Kevin Camp

    October 22, 2010 at 11:09 pm

    not to discurage you from trying to do this completely mathmatically with an expression, but a simple wya is to create the 2 keyframes (0% to 100%), then add a loopOut() expression.

    loopOut("pingpong");

    should do what you are asking.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Jan Heybowitz

    October 22, 2010 at 11:26 pm

    ah thanks. i understand the problem.
    what i don’t understand is where to find a starting point to solve this problem. =)

    here is a short description of what i’m trying to do:
    i have an array of pre-comps that should scale up one by one over 0.5 seconds and disappear again. looped. this expression should be coupled with a slider control to offset the starting point for each pre-comp.

  • Jan Heybowitz

    October 22, 2010 at 11:32 pm

    thanks, .. works perfectly. =)

  • Hannes Paulsson

    October 27, 2010 at 10:37 am

    Do you want it to just go in a smooth curve from 0 to 100 and than back to 0?

    in that case, usa i sinus curve. Like this:

    Math.sin(time*Math.PI*2)*50+50

    The Math.PI*2 tells it to do one loop in one second. Change this value to change the speed of this.

    If you just want it to scale up to 100 and then jump back to 0, just write:

    time*25%100

    change “25” to change the speed

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