Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions A better way to write this?

  • A better way to write this?

    Posted by Eric Sanderson on July 25, 2012 at 4:54 pm

    I like to think i know just enough about expressions to mess a lot of stuff up lol. The following “works”, as in doesn’t break but it makes AE run unusably slow. Its pretty straight forward, i have a grid of tiles animating into the screen, via valueAtTime referencing the null. I often do this and set up a sort of Random rig as you see, creating controls for the seedRandom and random amount on the valueAtTime. But what you see here is my first attempt at being able to activate that Random with a checkbox, which is where things really slow down. I figured maybe instead of randomizing the actual time referenced, it would be faster to randomize the index its referencing, up to numLayers, i dunno, thats why i turn to the experts. Hoping i can get this running faster and learn a thing or 2 in the process. Thanks so much.

    anim01 = thisComp.layer(index-1).transform.zPosition.valueAtTime(time-thisComp.layer("controller").effect("tDelay")("Slider"));

    seedRandom(index+thisComp.layer("controller").effect("Random Seed")("Slider"),true);

    r=random(0,thisComp.layer("controller").effect("Random Spread")("Slider"));

    anim02 = thisComp.layer(index-1).transform.zPosition.valueAtTime(time-r);

    check = thisComp.layer("controller").effect("Randomizer")("Checkbox");

    if(check==true){anim02
    }else{
    anim01
    }

    Dan Ebberts replied 13 years, 9 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    July 25, 2012 at 5:20 pm

    I don’t know how much this would speed it up, and I haven’t tested this code, but I’d set it up like this:


    ctl = thisComp.layer("controller");
    check = ctl.effect("Randomizer")("Checkbox");
    if (check)
    delay = random(0,ctl.effect("Random Spread")("Slider"))
    else
    delay = ctl.effect("tDelay")("Slider"));

    thisComp.layer(index-1).transform.zPosition.valueAtTime(time-delay);

    Dan

  • Eric Sanderson

    July 25, 2012 at 6:47 pm

    Well it made the comp responsive again so thats a win. For the “(check)”, does it just default to checking if thats true or not if you don’t actually write out a condition, defaulting to a boolean i guess it would be right?

  • Dan Ebberts

    July 25, 2012 at 6:55 pm

    That’s correct. Since the value of the checkbox will be 1 or 0, that will be interpreted as true or false.

    Dan

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