AS3-esque timer in Javascript