Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Expression Keyframing?

  • Expression Keyframing?

    Posted by N2gether on September 26, 2007 at 10:37 am

    Hi guys,

    I’ve created a 3D hallway with a camera moving down through it. As you move down the room the next bit of text is shown in front of the camera. The problem Iam having is getting the camera property ‘Focus Distance’ to focus in on each bit of text as the camera moves down the hallway. Iam using the following expression:

    length(thisComp.layer(“NameOfTextLayer”).transform.position,transform.position)

    ..which works perfect, but only for the first text layer. I can’t work out how to change the expression for this (or any) property further along the timeline (like keyframing). So I can’t change the expression to focus on any other layer 5sec down the timeline for example.

    What Iam trying to say is, is there a way to change “NameOfTextLayer” in the above expression at different positions on the timeline?

    E.g. 1sec = length(thisComp.layer(“Text1”).transform.position,transform.position)
    5sec = length(thisComp.layer(“Text2”).transform.position,transform.position)

    I tried to use Animation > Keyframe Asssitant > Convert Expression to Keyframes, but that didn’t seem to do anything.

    Thanks for any help in advance,
    Tom

    Dan Ebberts replied 19 years ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 26, 2007 at 2:37 pm

    Are you using CS3? If so, the best way would probably be to use markers where the marker comment is the name of the current layer to focus on. If not, then you can hard code everything (times and layer names) into arrays and have the expression loop through the time array until it finds the appropriate time, then use the corresponding layer name for the focus distance. Either way, help is available if you need it.

    dan

  • Dan Ebberts

    September 26, 2007 at 3:26 pm

    Here’s the AE7 method:

    switchTime = [0,1,5,7];
    targetName = [“Text1″,”Text2″,”Text3″,”Text4”];

    // find switch time

    idx = 0;
    for (var i = 0; i < switchTime.length; i++){ if (time >= switchTime[i]) idx = i else break;
    }

    currentTarget = thisComp.layer(targetName[idx]);
    length(currentTarget.transform.position,transform.position)

    Dan

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