I wrote a timeout/ interval function where you can pass the symbol, the start time and end time and it will keep calling itself and advancing the timeline until it reaches the end time. It's only 12 lines.
function timerFunction(startms, targetms, addinc, asymbol) {
//startms is the timeline starting point, usually where it is at the beginningof all this
//targetms is the desired timeline position
//addinc is the milliseconds you want the settimeout to wait, I use 500
// asymbol is the function with the timeline you want to control. Note: it is being passed around here be reference, not copies which is good.
//so call it like this: timerFunction(freqsym.getPosition(), 1800, 100, freqsym)
var ms;
//console.log(" startms: " + startms + ", targetms: " + targetms +", addinc: " + addinc );
if ( addinc < Math.abs(startms - targetms ) ) {
ms = startms + addinc;
asymbol.stop(ms);
//500 = 1/2 second = the delay the time interval will wait:
setTimeout( timerFunction, 500, ms, targetms, addinc, asymbol);
} else {
//finished
ms = targetms;
asymbol.stop(ms);
}
}