Copy link to clipboard
Copied
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.
It appears to work just as you describe. Seems like a bug (at least the scripting part, but maybe both) to me.
Dan
Copy link to clipboard
Copied
It appears to work just as you describe. Seems like a bug (at least the scripting part, but maybe both) to me.
Dan
Copy link to clipboard
Copied
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 ?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Ok. Sticking to comp.time too then. Thank you.
Xavier.
Copy link to clipboard
Copied
still not fixed in Ae 2024 I guess
nearestKeyIndex works unexpected while layer time reversed