Highlighted

Check for keyframe on another layer

New Here ,
Apr 10, 2020

Copy link to clipboard

Copied

I have two layers, A and B. LayerA is a precomp containing drawings for an animation, with time remapping keyframes to display the drawings in the correct locations on the timeline. LayerB is a precomp containing a sequence of 5 texture images. I'd like to write an expression on LayerB to change the frame it is displaying whenever a keyframe is present in LayerA.

 

I found the following expression on this forum which works well, although I'd like to understand better what var t is. I know it is used to break the for loop but that's about it.

seedRandom(1,true);
var t=timeToFrames();
var r1=-3;
var r2=-2;
var r3=-1;
for (var i=0;t>=i; i++) {
   var r3=Math.floor(random(5));
   if (r1==r3 || r2==r3) {
      t++;
      continue;
   }
   r1=r2;
   r2=r3;
}
framesToTime(r3);

As for checking for the presence of a time remap keyframe on another layer, I'm clueless as to where to start. Any advice would be appreciated.

 

TOPICS
Expressions

Views

42

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Check for keyframe on another layer

New Here ,
Apr 10, 2020

Copy link to clipboard

Copied

I have two layers, A and B. LayerA is a precomp containing drawings for an animation, with time remapping keyframes to display the drawings in the correct locations on the timeline. LayerB is a precomp containing a sequence of 5 texture images. I'd like to write an expression on LayerB to change the frame it is displaying whenever a keyframe is present in LayerA.

 

I found the following expression on this forum which works well, although I'd like to understand better what var t is. I know it is used to break the for loop but that's about it.

seedRandom(1,true);
var t=timeToFrames();
var r1=-3;
var r2=-2;
var r3=-1;
for (var i=0;t>=i; i++) {
   var r3=Math.floor(random(5));
   if (r1==r3 || r2==r3) {
      t++;
      continue;
   }
   r1=r2;
   r2=r3;
}
framesToTime(r3);

As for checking for the presence of a time remap keyframe on another layer, I'm clueless as to where to start. Any advice would be appreciated.

 

TOPICS
Expressions

Views

43

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 10, 2020 0
Mylenium LATEST
Most Valuable Participant ,
Apr 11, 2020

Copy link to clipboard

Copied

Not sure what you need to know. Isn't it obvious what a verbose functiuon called timeToFrames() does? It's literally spelled out.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 11, 2020 0