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.