# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Timecode Expression

• # Timecode Expression

2 Members · 3 Posts
• ### Scott McGee

February 26, 2019 at 12:48 pm

Just because someone has asked a question and it’s made me think.

How can you use an expression on time use the timecode to trigger.

eg

If (time < 2) 100 else 0;

if I do frames this also works

if (time < framesToTime(65)) 100 else 0;

But how can you use the timecode to do the same

if (time < timeToTimecode(00:00:02:00)) 100 else 0;

This doesn’t work and I can’t fathom how to do it another way. Surely if it works for time and frames. It can do timecode.

• ### Alex Printz

February 26, 2019 at 4:14 pm

isn’t timecode technically a string? You would need a function timecodeToTime(t), which after effects doesn’t have, to get it to be comparable.

To build the function you you would need to parse out the separate elements of the timecode and combine them appropriately, e.g.:

t = 00:00:02:00;

var f = 0;
for(i=0; i<4; i++){
d = t.split(“:”)[i];
try{d = d.split(“:”)[0]}catch(e){};
f += parseInt(d);
if(i<2) f*=60;
if(i==2)f*=(1/thisComp.frameDuration);
} framesToTime(f)

Alex Printz
Mograph Designer

• ### Scott McGee

February 27, 2019 at 8:41 am

Cheers Alex,

I would never have thought of doing that.

I did get an error back because the timecode wasn’t in “”, but then it worked perfectly

t = “00:00:02:00”;

var f = 0;
for(i=0; i<4; i++){
d = t.split(“:”)[i];
try{d = d.split(“:”)[0]}catch(e){};
f += parseInt(d);
if(i<2) f*=60;
if(i==2)f*=(1/thisComp.frameDuration);
}

if(time < framesToTime(f)){
100
}else{
0
};

Viewing 1 - 3 of 3 posts