Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › timeline expression

  • timeline expression

    Posted by Aaron Magee on September 17, 2010 at 1:20 pm

    Hello-

    I’m trying to create set-up in After Effects where I can change some text by using checkboxes.

    Right now I have a comp where I’ve animated the source text to change every frame, so I have a keyframe on frames 1 through 5. I will want to expand this later, but for now it’s just for testing puposes.

    What I want to do is control the timeline in this comp from another comp using checkbox controls to navigate the keyframes in the comp with the keyframes in it.

    I’m stuck on how to do this. Is there a way in AFter Effects to do this with expressions?

    I’d appreciate any help, and I can clarify this if anyone needs further explanation.

    -Aaron

    Dan Ebberts replied 16 years ago 3 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    September 17, 2010 at 3:56 pm

    It sounds like you should be able to do it with a source text expression that somehow converts your checkbox configuration to a frame number. The expression would look something like this (assuming that the first part of the expression calculates the frame number:

    //calculate value of f here
    valueAtTime(framesToTime(f) + .001)

    Something like that. Hard to be more specific without knowing what you have in mind for the checkboxes.

    Dan

  • Aaron Magee

    September 17, 2010 at 4:31 pm

    Dan-

    I want the checkboxes to move to a certain keyframe in the comp that has the source text animated.

    The checkboxes are different times i.e. 7|6c , 8|7c etc. and I want the checkbox to move the timeline control and hold on the frame associated in the other comp that has the source text animated to switch the times around.

    This is all to avoid having to type the numbers manually, and just use checkboxes to “turn times off/on”.

    I’m trying to figure out a solution that dosent involve having an expression on a whole bunch of layers.

    I hope this makes sense. Thanks for your help.

    Aaron

  • Dan Ebberts

    September 17, 2010 at 5:19 pm

    I think it’s going to be a source text expression that looks like this:


    C = comp("Control Comp").layer("Controls");
    if(C.effect("Checkbox Control")("Checkbox").value == 1)
    f = 0
    else if (C.effect("Checkbox Control 2")("Checkbox").value == 1)
    f = 1
    else if (C.effect("Checkbox Control 3")("Checkbox").value == 1)
    f = 2
    else if (C.effect("Checkbox Control 4")("Checkbox").value == 1)
    f = 3
    else if (C.effect("Checkbox Control 5")("Checkbox").value == 1)
    f = 4
    else
    f = 0;

    valueAtTime(framesToTime(f) + .001)

    Although, I think I’d be tempted to do it with a slider or an angle control rather than checkboxes.

    Dan

  • Aaron Magee

    September 17, 2010 at 7:13 pm

    NICE !

    Everything works great. I’m going to try and use an angle control and see what happens.

    What is this for: valueAtTime(framesToTime(f) + .001) ?

    And is the “f” something AE understands already?

    -Aaron

  • Dan Ebberts

    September 17, 2010 at 9:41 pm

    >What is this for: valueAtTime(framesToTime(f) + .001) ?

    That’s the part of the expression that retrieves the text from the appropriate frame, based on the variable f. It converts the frame number (f) to a time, adds in a little fudge factor (.001 sec.)to make sure it’s on the correct side of the keyframe, and uses valueAtTime() to retrieve the text at that time.

    >And is the “f” something AE understands already?

    No, it’s a variable defined by the expression and set equal to the frame number appropriate to the first selected checkbox the expression finds.

    Dan

  • Kevin Camp

    September 17, 2010 at 11:46 pm

    i’ve done very similar things by using an expression to build arrays from the source text. then using some other logic to drive the array index, in your case, maybe just a slider control.

    the expression is quite simple, and unless something else is happening to the text in the pre-comp, the text layer could reside in the main comp, and the slider could be directly on the text layer…

    in a situation like that the expression is fairly simple:

    indx = effect(“Slider Control”)(“Slider”);
    timeArray = text.sourceText.split(‘\r’);

    timeArray[Math.floor(indx%timeArray.length)]

    then you’d just type (copy/paste) the times into the text field using returns in between the times.

    you can use the same slider to control an array of show titles too, that way the show name and time could be linked… in a case like that, you might want the slider on a null.

    to lazy to sit around and render each one separately… you can link the ‘indx’ value to the comp name, then just duplicate the comp (which will automatically add a number to the end of the comp name, which you can use to drive the ‘indx’) and add them to render queue.. hit render and go home….

    just modify the first line to something like this:

    CompNum = thisComp.name.split(‘ ‘);
    indx = CompNum[CompNum.length-1]-1;

    you could have the ‘indx’ show/hide image layers in nested comp, if your shows had images/video or logos or other specifics too…

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Dan Ebberts

    September 18, 2010 at 1:09 am

    Wouldn’t you have to parse the number part of the comp name?

    indx = parseInt(CompNum[CompNum.length-1],10)-1;

    Dan

  • Kevin Camp

    September 18, 2010 at 8:36 pm

    hi dan,

    what would parseInt do vs. just returning the last part of the comp name (which should just be a number, assuming the comp was just duplicated)?

    i’m always looking for new ways to exploit expressions in ae, and i’ve been using another broadcast box that utilizes scripting that is much more like vb script, and i’ve found that a fair amount of java that i have learned for expressions has been helpful with that system.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Dan Ebberts

    September 18, 2010 at 9:26 pm

    Well, I have to admit I haven’t tried it, but split() gives you an array of strings, so CompNum[CompNum.length-1] should be the string representation of the comp number. I’d think you’d need to convert it to an integer before you’d want to use it as a number. parseInt() will do that.

    Dan

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