Skip to main content
UQg
Legend
January 4, 2015
Answered

nearestKeyIndex with time reversed layers

  • January 4, 2015
  • 2 replies
  • 998 views

i just observed a wierd behaviour of nearestKeyIndex with negatively stretched layers and am wondering whether this is intended:

setup: put a footage inside a comp, time reverse the layer, lay some position keyframes on that layer.

1- expression: add a slider control to the time reversed layer, with expression: "transform.position.nearestKey(time).index;",  scroll the CTI along the timeline and read the slider value: the first key on the timeline has max index, the last key has index 1...

2- script: var L=app.project.activeItem.layer(1); L.transform.position.nearestKeyIndex(L.containingComp.time);     If the CTI is placed after the last position key on the timeline, it returns L.transform.position.numKeys, which is expected. But anywhere else it gives 1 !

So, for expressions it is more or less ok, but it means that whenever one uses a "nearestKey" expression one should actually check the strech state of the layer...(if (layer.inPoint<layer.outPoint) {this} else {that};)

But the script function looks really bugged to me, unless i made something wrong. Can someone confirm that "observation" ?

The work around i have now is to precomp the footage, time reverse it inside the precomp, and animate the precomp. But i'd rather not do it like that.

Xavier.

This topic has been closed for replies.
Correct answer Dan Ebberts

It appears to work just as you describe. Seems like a bug (at least the scripting part, but maybe both) to me.

Dan

2 replies

Participating Frequently
February 22, 2024

still not fixed in Ae 2024 I guess

nearestKeyIndex works unexpected while layer time reversed

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
January 4, 2015

It appears to work just as you describe. Seems like a bug (at least the scripting part, but maybe both) to me.

Dan

UQg
UQgAuthor
Legend
January 5, 2015

Thank you Dan for checking.

I'll quote it as answered since it makes me stop wondering about that problem, but i'll file a bug report along.

Xavier.

Side question:

I always use [layer].containingComp.time instead of just [layer].time, to be absolutely sure that it is the time i want, but everytime i check they appear to be the same.

Do you know if this is always true ?

Dan Ebberts
Community Expert
Community Expert
January 6, 2015

I'm not aware of a case where they can be different. I tried it with a layer open in its own viewer and changing one changes the other. I do always use the comp time though, just in case.  :-)

Dan