2 Replies Latest reply on Oct 5, 2012 7:42 AM by ross_design

    Expression Issues

    ross_design

      Hi All,

       

      I am trying to do what I thought was a relativly simple expression but after litterally hours and serveral variations I am no further forward.

       

      Essentially I have 2 objects; 1 null and 1 graphic - both 2D.

       

      The graphic moves vertically controlled by a combination of keyframes (to gradually move it from the top to the bottom of the comp) and a wiggle expression (in turn controlled by a slider) to make its movement more turbulent.

       

      [value[0],wiggle(1,effect("Slider Control")("Slider"))[1]]

       

      This all works fine.

       

      What I am trying to do is make the null stay at the lowest y position the graphic has reached - should almost look like the graphic is pushing the null down by jumping on it.

       

      The expression I have is this:

       

      a = thisComp.layer("Graphic1").transform.position[0];

      b = thisComp.layer("Graphic1").transform.position[1];

       

      v=value[0];

      w=value[1];

       

       

      if(b>w){

      w=value[1];

      [v,b]

      }else{

      [v,w]

      }

       

      It sort of works - the null stays attached to Graphic1 but wont go above its start position.

      What I think is going wrong is that w doesnt update itself so it is stuck at its first frame position and ignores the new y position (gennerated by the wiggle expression).
      Unfortunatly I can just keyframe this and re-structure using pre-comps as this is only a small part of a much bigger beast that uses aroun 50 elements all using various elements.

       

      Thanks for your help

        • 1. Re: Expression Issues
          Mylenium Most Valuable Participant

          Not sure what you are hoping to achieve. In your case w is defined as value[1], which is the property base value - before any expressions. Naturally it never changes and your expression is therefore useless. Anyway, your simplitic code can't achieve what you want. You need to construct a while() loop and accumulate values with valueAtTime() or something like that or as a minor do something with Math.max() to return only the largest possible value at a given time. There's enouzgh examples on Dan Ebberts' site, but it's not gonna be your usual Andrew Kramer 5 second expression...

           

          Mylenium

          • 2. Re: Expression Issues
            ross_design Level 1

            Thanks Mylenium, thats alot of help.
            What im trying to achieve is a massivly complex task and just getting bogged down as a dont know the correct syntax to use. Looks like iv got everything I need on Dan Ebberts site.

            Thanks.