Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions After Effects Expression that measures the length of a layer

  • After Effects Expression that measures the length of a layer

    Posted by Emotiondesigner on May 27, 2006 at 12:38 am

    I want to automate some of my animations.
    I saw a tutorial that explained how to write an expression that would measure the length of a layer so that a slide and fade of a layer could be automated to slide the layer into position at the beginning of the layer and slide it out of position at the end of the layer. The same script could be applied to opacity, or any other attribute, so that you could create your own pre-sets.

    It was great because you could apply it as a preset and instead of adding tons of key frames, you could just adjust the length of the layer and it would move in and move out.

    However, I can’t find the tutorial anywhere. I was wondering if anyone out there would know how to set that up?

    Wes Plate replied 19 years, 11 months ago 3 Members · 2 Replies
  • 2 Replies
  • Colin Braley

    May 27, 2006 at 5:12 am

    I am not familiar with the tutorial you mention, but this kind of thing isn’t too difficult to do with expressions. Here are a few examples to get you started:

    This expression for opacity should make a layer fade in and out around the endpoints. Just modify the variable frames to your liking.

    //Begin expression
    frames = 10;//Duration of in/out animation
    //————
    if(time < this.inPoint + framesToTime(frames) ) ease(time, this.inPoint, this.inPoint + framesToTime(frames), 0, 100); else ease(time, this.outPoint - framesToTime(frames), this.outPoint, 100,0); //End expression This next expression for position should make a layer "Slide into place" as you mentioned. In this one, just modify the variables frames , initialPosition , and mainPosition.

    //Begin expression
    frames = 10; //Duration of in/out animation
    initialPosition = [260, -100]; //Position and beginning and end
    mainPosition = [360, 270]; //Main position
    //————
    if(time < this.inPoint + framesToTime(frames) ) ease(time, this.inPoint, this.inPoint + framesToTime(frames), initialPosition, mainPosition); else ease(time, this.outPoint - framesToTime(frames), this.outPoint, mainPosition,initialPosition); //End expression These kind of expressions can be used to do some more advanced stuff too. I used this ineffeciently coded position expression recently on a project to have a layer spiral in and out at its endpoints. frames = 30; //Duration of in/out animation initialPosition = [260, -100]; //Position and beginning and end mainPosition = [360, 270]; //Main position freq = 25;//Frequency of circular rotation maxAmp = 300;//Max amplitude minAmp = 0;//Minimum amplitude //------------ if(time < this.inPoint + framesToTime(frames) ){ amp = ease(time, this.inPoint, this.inPoint + framesToTime(frames), maxAmp, minAmp ); circle = [amp*Math.sin(time * freq), amp*Math.cos(time * freq)]; ease(time, this.inPoint, this.inPoint + framesToTime(frames), initialPosition + circle, mainPosition + circle ); }else{ amp = ease(time, this.outPoint - framesToTime(frames), this.outPoint, minAmp, maxAmp); circle = [amp*Math.sin(time * freq), amp*Math.cos(time * freq)]; ease(time, this.outPoint - framesToTime(frames), this.outPoint, mainPosition + circle, initialPosition + circle); } ~Colin

  • Wes Plate

    May 28, 2006 at 4:26 am

    It sounds like one of JJ Gifford’s web pages you saw…

    https://jjgifford.com/expressions/geometry/length.html

    — Wes Plate
    Automatic Duck

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