Thank you Martin!
Here is an another update. This is the version adapted for AnimatedLayer. Uses the same methods of animation as previously. The script can process any number of frames. Look at the example skin - both 64-frames and 13-frames animations are moving simultaneously. You can even compare 255-frames AnimatedLayer with the 10-frames one - they will have equal motion speed anyway.
Screenshot of the example skin